Implement BaseEnsemble
Description
One of the core elements of the Monte Carlo module is the BaseEnsemble, from which all other ensembles are derived.
It must provide basic functionality for running a Monte Carlo simulation as illustrated by the following snippet (see #113 (closed) for a more extensive use case). Here, Ensemble is a child of BaseEnsemble.
# set up simulation
ce = ClusterExpansion.read('mymodel.ce')
atoms = ce.primitive_structure.repeat(4)
mc = Ensemble(atoms, calculator=ce, data_container='myrun.dc', ...)
# attach an observer (child of BaseObserver)
obs = ShortRangeOrder(interval=10, mode='Warren-Cowley', neighbor_shells=3)
mc.attach_observer(obs, tag='sro')
# run MC
mc.run(steps=15000)
Upon initialization (and possibly also after changes to the interval parameters) the BaseEnsemble class must determine the greatest common denominator (gcd) of all the interval values and call the observers accordingly during the run phase.
The BaseEnsemble must initialize and handle the internal DataContainer (#158 (closed)) object.
This includes adding metadata
- date/time
- optional: user account name, machine name
and restart information
- complete set of input parameters (latest set in case the parameters are changed during simulation, see below)
- calculator (
ClusterExpansion)
as well as appending data as the simulation progresses (see #158 (closed)).
The ensemble could also be used to loop over ensemble parameter (e.g., the temperature)
for temperature in range(1000, 100, -10):
mc.reset_data_container()
mc.temperature = temperature
mc.run(steps=15000)
Here, temperature() is a property that is specific to e.g., the canonical, SGC, and VCSGC ensembles.
Care must be taken to ensure that observer tags are unique.
Other basic properties/variables to include:
- counters for total and accepted trials
- interval for storing elementary observables (possibly in sub MC cycle, float?)
Sub-tasks
-
define interface (using pass) -
setup of DataContainer -
add observers -
complete unit tests -
complete docstrings
Demonstration
-
all tests pass -
docstrings complete