This class embodies the trajectories generated by the Metropolis simulations in a Monte Carlo run at finite temperature.
MonteCarloTrajectory class
Objects of this class are used to store and access information of the trajectory generated from a Monte Carlo sampling performed with the MonteCarlo class.
It is initialized with the SuperCell object.
Alternative: If read
is True, it is initalized from a Json file with name filename
that
was created from a MonteCarloTrajectory object before by MonteCarloTrajectory.serialize()
.
Parameters:
scell
: SuperCell object (default: None)Super cell in which the sampling is performed.
filename
: string (default: trajectory.json)The trajectoy can be stored in a json file with the path given by filename
.
read
: boolean (default: False)If True, the trajectory is read from the Json file filename
.
**kwargs
: keyword arguments
models
: List of Model objectsFurther keyword arguments can be used to store additional information about the parameters used for the MonteCarloTrajectory.metropolis rountine. This will be saved in the Json file
filename
undersampling_info
, if the object is serialized.
Add entry of the structure visited in the sampling to the trajectory.
prop_name
after discarding at the start a given number of equilibration steps. The average can only be obtained from a property that was already calculated before, e.g. by MonteCarlo.Trajectory.calculate_properties(…).
Alternatively, an external function average_func
can be used to calculate the average of one property
or several properties. The function average_func
has as arguments an array containing the properties
used for the average at each sampling index, i.e. [[prob1_1,prop1_2,…,prop1_N], [prop2_1,prop2_2,…,prop2_N],…],
and optional keyword arguments. With prop_list
, the property names of prob1, prop_2, … are defined.
Parameters:
prop_name
: string (default: U
)Name of property that is averaged. If C_p, the isobaric specific heat at zero pressure is calculated. If U, the internal energy is calculated.
no_of_equilibration_steps
: integerNumber of equilibration steps at the start of the Monte-Carlo sampling that are discarded from the average.
average_func
: function (default: None
) If not None, the averaged property is obtained by this function. It gets as arguments an array and optional keyword arguments.
**kwargs
: keyword argumentsAdditional arguments for average_func
.
calculated by a Model object or an external function prop_func
.
models
: list (default: empty list)
prop_func
: function (default: None)This function recieves as arguments the Structure object and the dictionary
of trajectory entry at step i, and additional keyword arguments given by **kwargs
.
prop_name
: string (default: None)Name of property which is calculated by prop_func
.
**kwargs
: keyworded argument list, arbitrary lengthAdditional parameters for the function prop_func
Return energies of all entries in trajectory as array.
Return energy of entry at index nid
in trajectory.
Return structure in form of a Structure object with the lowest energy in trajectory.
Return entry index at the n-th sampling (nstep
) step in trajectory.
Return array of integers, that are the indices of the entries in trajectory for which the property
prop
has the value value
.
Return the property prop
from all entries in the trajectory as array.
Return property of entry at index nid
in trajectory.
Return the entry, e.g. the dictionary stored at index nid
in trajectory.
Return the entry, e.g. the dictionary stored for the n-th samplig step (nstep
) in trajectory.
Return sampling step number of entry at index nid
in trajectory.
Return sampling step numbers of all entries in trajectory as array.
Return structure in form of a Structure object, at index nid
in trajectory.
Return structure in form of a Structure object, at the n-th sampling step (nstep
) in trajectory.
Read trajectory from the Json file with name filename
. If filename
is not defined, it uses
trajectory file name defined in the initialization of the MonteCarloTrajectory.
Write trajectory to Json file with name filename
. If filename
is not defined, it uses
trajectory file name defined in the initialization of MonteCarloTrajectory object.