pele.mc.MonteCarlo#

class pele.mc.MonteCarlo(coords, potential, takeStep, storage=None, event_after_step=None, acceptTest=None, temperature=1.0, confCheck=None, outstream=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>, store_initial=True, iprint=1)[source]#

A class to run the Monte Carlo algorithm

Parameters:
coordsnumpy array, one dimensional

The initial set of coordinates.

potentialpotential object

A class implementing the potential. The class must have the following functions implemented:

potential.getEnergy(coords)
potential.getEnergyGradient(coords)
takeStepobject

The class which randomly perterbs the system, e.g. random displacement. It must have two functions implemented which are called like:

takeStep.takeStep(coords, driver=self)       #  takes the step
takeStep.updateStep(acceptstep, driver=self) #  for adaptive step size management
acceptTestcallable, optional

Acceptance criterion for monte carlo move. If None is given, metropolis is used. It must have the form:

bool = acceptTest(Eold, Enew, old_coords, new_coords)
confChecklist of callables, optional

list of checks if current configuration is valid. This is executed before acceptTest and accepTest is only called if all checks return True. The checks are called like:

check(trial_energy, trial_coords, driver=self)

and must return a bool

temperaturefloat, optional

The temperature used in the metropolis criterion.

event_after_steplist of callables, optional

these are called just after each monte carlo round. Each event in the list takes the form::

event(energy, coords, acceptstep)
outstreamopen file object, optional

The file stream to print quench information to. None for no printing. Default to standard out.

store_initialbool, optional

if True store initial structure

Methods

addEventAfterStep(event)

add an even to the list event_after_step

printStep()

run(nsteps)

do multiple iterations

setPrinting([ostream, frq])

change how the printing is done

takeOneStep()

one cycle of the routine

Attributes