Gibbs Ensemble

Simulations directly sampling phase coexistence risk overrepresenting the interfaces between phases unless system sizes are substantially large. Gibbs Ensemble techniques allow for the simulation of phase coexistence without introducing large system sizes. Instead, they simulate the two phases separately and allow them to exchange particles and alter their volumes, with the aim of reaching equal temperatures, pressures, and chemical potentals.

OpenFTS includes the Gibbs Ensemble technique through the GibbsEnsemble class. An example using GibbsEnsemble is provided here

import openfts
fts = openfts.OpenFTS()                       # create an fts object
...                                           # edit the fts object
optimizer = openfts.GibbsEnsemble(fts)        # create a GibbsEnsemble object
state0 = gibbs.create_state()                 # create and overwrite the GibbsEnsemble state
gibbs.state_updater(...)                      # ...

where below is the comprehensive API to interface with GibbsEnsemble (generated via sphinx.autodoc).

class openfts.GibbsEnsemble(fts)
create_state(filename=None, statetype='phi')

helper function to create a state to be used as an initial condition. if filename is provided, state is loaded from jsonfile Initial state of the Gibbs Ensemble solver (dict). Should specify ‘C’ of each phase and ‘nu’ and ‘phi_i’ of each phase - 1. This object can be created using the gibbs.create_state()

get_final_state()
initial_state(state)

set initial state for gibbs solver

run(nsteps, rtol=0.001, continue_run=False, log_freq=1, plot_freq=10, preserve_fields=False, init_fields_filenames=None)

Run the Gibbs Ensemble

Args:

nsteps: (int) number of Gibbs steps to take rtol: (float) relative tolerance to check convergence continue_run: (bool) whether to continue existing run or to start a new one log_freq: (int) frequency to generate stdout plot_freq: (int) frequency to generate plots preserve_fields: (bool) whether to initialize fields using final fields from prior step (currently not implemented!) init_fields_filenames: (list) list of filenames with field files to use for initializing FTS simulaitons. Length should be equal to number of phaess

state_updater(**kwargs)

set state_updater parameters

Args:

type: (str) type of state updater. Options: ‘Euler’, … mode: (str) mode to use for updating state. Options: ‘phi’,’rho’,’n’ dt_mus: (float, list) timesteps to use to update phi/rho/n. Can be a list to specify a different value for each molecule, or can be a single value that will be used for all molecules. dt_P: (float) timestep to use to update box volumes

write_status(status)

write STATUS to a file. Use same convention as OpenFTS: (0) running (1) error (2) converged (3) reached max steps