This commit is contained in:
Yael-II
2025-01-19 17:31:02 +01:00
parent 34371f3532
commit 6b06be4a6b
27 changed files with 337 additions and 32 deletions

View File

@@ -1,3 +1,15 @@
#!/usr/bin/env python
"""
Initial Conditions
Generate initial conditions depending on different criteria
@ Author: Moussouni, Yaël (MSc student) & Bhat, Junaid Ramzan (MSc student)
@ Institution: Université de Strasbourg, CNRS, Observatoire astronomique
de Strasbourg, UMR 7550, F-67000 Strasbourg, France
@ Date: 2024-11-29
"""
import numpy as np
import matplotlib.pyplot as plt
POS_MIN = -1
@@ -12,12 +24,14 @@ def mesh_grid(N: int = N_PART,
ymin: float = POS_MIN,
ymax: float = POS_MAX) -> np.ndarray:
"""Generates a set of regularly sampled particles with no velocity
:param N: number of particles
:parma xmin: Minimum value for position x
:param xmax: Maximum value for position x
:param ymin: Minimum value for position y
:param ymax: Maximum value for position y
:returns W: Phase-space vector
@ params:
- N: number of particles
- xmin: minimum value for position x
- xmax: maximum value for position x
- ymin: minimum value for position y
- ymax: maximum value for position y
@ returns:
- W: phase-space vector
"""
X = np.linspace(xmin, xmax, N)
Y = np.linspace(ymin, ymax, N)
@@ -30,10 +44,14 @@ def one_part(x0: float = 0,
v0: float = 0) -> np.ndarray:
"""Generates a particle at position (x0, y0)
with velocities (u0,v0)
:param x0: Initial position x
:param y0: Initial position y
:param u0: Initial velocity u
:param v0: Initial velocity v
@ params:
- N: number of particles
- x0: initial position x
- y0: initial position y
- u0: initial velocity u
- v0: initial velocity v
@ returns:
- W: phase-space vector
"""
X = x0
Y = y0
@@ -48,6 +66,18 @@ def n_energy_part(potential,
xmax: float = +1,
ymin: float = -0.5,
ymax: float = +1):
"""Generates N particles with an energy E in a potential.
@ params:
- potential: gravitational potential
- N: number of particles
- E: total energy
- xmin: minimum value for position x
- xmax: maximum value for position x
- ymin: minimum value for position y
- ymax: maximum value for position y
@ returns:
- W: an array of all the positions and velocities.
"""
X = []
Y = []
POT = []
@@ -81,6 +111,22 @@ def n_energy_2part(potential,
xmax: float = +1,
ymin: float = -0.5,
ymax: float = +1):
"""Generate a sample of 2N particles with the energy E in a potential in
two sets: one "normal" set (see n_energy_part), and a slightly shifted set
with a separation sep.
@ params:
- potential: gravitational potential
- N: number of particles
- E: total energy
- sep: the separation between the two sets
- xmin: minimum value for position x
- xmax: maximum value for position x
- ymin: minimum value for position y
- ymax: maximum value for position y
@ returns:
- (W1, W2): the two arrays of all the positions and velocities for
each set.
"""
W_1 = n_energy_part(potential, N, E)
W_2 = np.zeros_like(W_1)
alpha = np.random.uniform(0, 2*np.pi, N)