Model builder¶
Model builder. Stores and defines physical properties of a group of atoms.
The model handles two species of atom (one of them can be ignored by setting the correct mole fraction). The first species values are stored in the first part of arrays (lower indices), the second species in what lasts (higher indices). This is meant to facilitate computation of inter-atomic forces and potential energy.
-
class
moldyn.simulation.builder.
Model
(pos=None, v=None, npart=0, x_a=1.0)[source]¶ - Parameters
pos (np.array) –
Atoms’ position.
Note
If v is not set, it is initialized as an array full of zeros.
v (np.array) –
Atoms’ speed.
Note
Taken in account only if pos is set.
npart (int) –
Total number of atoms.
Note
Setting pos overrides this.
x_a (float) – Mole fraction of species A.
-
T
¶ Temperature. Is calculated from the average kinetic energy of the atoms. May be set to any positive value, in which case atoms’ speed will be scaled to match the desired temperature.
- Type
float
-
EC
¶ Microscopic kinetic energy.
Note
Cannot be changed as-is, but setting
T
is one way to do so.- Type
float
-
total_EC
¶ Total kinetic energy.
Note
Cannot be changed as-is.
- Type
float
-
kB
¶ Boltzmann constant. If changed, will affect the way the model behaves regarding temperature.
- Type
float
-
pos
¶
-
v
¶ List of atom positions and speeds. First axis represents the atom, second axis the dimension (x or y).
- Type
np.array
-
dt
¶ Timestep used for simulation.
Note
An acceptable value is calculated when species are defined, but it may be set to anything else.
- Type
float
-
npart
¶ Total number of atoms.
- Type
int
-
x_a
¶ Mole fraction of species A.
- Type
float
-
n_a
¶ Atom number for species A, calculated from
x_a
andnpart
If set,x_a
will be recalculated.- Type
int
-
epsilon_a
¶
-
epsilon_b
¶ Epsilon value (J, in Lennard-Jones potential) for species a or b.
- Type
float
-
sigma_a
¶
-
sigma_b
¶ Sigma value (m, in Lennard-Jones potential) for species a or b.
- Type
float
-
epsilon_ab
¶
-
sigma_ab
¶ Inter-species epsilon and sigma values.
Note
Cannot be changed as-is. If you want to change these values, modify the corresponding items in the
params
dictionary.- Type
float
-
re_a
¶
-
re_b
¶
-
re_ab
¶ Estimated radius of minimum potential energy.
- Type
float
-
rcut_fact
¶ When the model is simulated, atoms further than
rcut_fact*re
do not interact. Defaults to 2.0.- Type
float
-
params
¶ Model parameters, needed for the simulation.
Warning
Changing directly these values may lead to unpredicted behaviour if not documented.
- Type
dict
-
kong
¶ Kong rules to estimate inter-species sigma and epsilon parameters.
- Type
dict
-
inter_species_rule
¶ Rules to automatically estimate inter-species sigma and epsilon parameters. Defaults to
kong
.- Type
dict
-
x_lim_inf
¶
-
y_lim_inf
¶ Lower x and y position of the box boundaries.
- Type
float
-
x_lim_sup
¶
-
y_lim_sup
¶ Upper x and y position of the box boundaries.
- Type
float
-
length_x
¶
-
length_y
¶ Size of the box along x and y axis. Those parameter are tied with *_lim_*** and any change on one of them is correctly taken in account.
- Type
float
-
lim_inf
¶
-
lim_sup
¶
-
length
¶ 2 elements wide array containing corresponding
(x_*, y_*)
values.Note
Cannot be changed as-is.
- Type
np.array
-
x_periodic
¶
-
y_periodic
¶ Defines periodic conditions for x and y axis. Set to 1 to define periodic boundary condition or 0 to live in an infinite empty space. Defaults to 0.
- Type
int
-
mass
¶ Total mass in the model.
Note
Cannot be changed as-is.
- Type
float
-
m
¶ Mass of each atom. Shape is
(npart, 2)
in order to facilitate calculations of kinetic energy and Newton’s second law.Warning
You should not change those values unless you know what you are doing.
- Type
np.array
-
atom_grid
(n_x, n_y, d)[source]¶ Creates a grid containing
n_x*n_y
atoms.- Parameters
n_x (int) – number of columns
n_y (int) – number of rows
d (float) – inter-atomic distance
-
random_speed
()[source]¶ Gives a random speed to the atoms, following a normal law, in order to have a strictly positive temperature.
-
set_a
(epsilon, sigma, m)[source]¶ Sets species a parameters.
- Parameters
epsilon (float) – Epsilon in Lennard-Jones potential.
sigma (float) – Sigma in Lennard-Jones potential.
m (float) – Mass of the atom.
-
set_ab
(a, b)[source]¶ Sets species a and b parameters, and calculates inter-species parameters.
- Parameters
a (tuple) – First species parameters, under the form
(epsilon, sigma, mass)
b (tuple) – Second species parameters, under the same form.
-
set_dt
(dt=None)[source]¶ Defines the timestep used for simulation.
- Parameters
dt (float) – Desired timestep. If not set, will be calculated from species a’s properties.
-
set_periodic_boundary
(x=1, y=1)[source]¶ Set periodic boundaries on both axis.
- Parameters
x (int) – see
x_periodic
y (int) – see
y_periodic