Python Module API

In order to run OpenFTS as a python module, your python script will look something like

import openfts
fts = openfts.OpenFTS()   # create fts object
...                       # edit the fts object
fts.run()                 # run the fts object
...                       # extract data from fts run

Below is the comprehensive API to interface with this fts object (generated via sphinx.autodoc)

class openfts.OpenFTS

Python interface to OpenFTS C++ backend.

add_molecule(type, **kwargs)

Add a new molecule to OpenFTS object. See elsewhere in documentation for description of args.

add_monitor(**kwargs)

Add a new monitor to OpenFTS object. See elsewhere in documentation for description of args.

add_operator(**kwargs)

Add a new operator to OpenFTS object. See elsewhere in documentation for description of args.

add_species(**kwargs)

Add a new species to OpenFTS object. See elsewhere in documentation for description of args.

cell(**kwargs)

Initialize cell of OpenFTS object. See elsewhere in documentation for description of args.

compute_optimal_npw(prime_factors=[2, 3], min_smearing_length=None, cell_lengths=None)

Using cell size and minumum species smearing length compute optimal npw using localfts object

Parameters:
  • prime_factors – list of prime integer factors for allowed npw

  • min_smearing_length – Minimum smearing length to resolve in box. If unspecified, defaults to use values from the diferent species in box (this option was added to support Gibbs ensemble simulations)

  • cell_lengths – Cell lengths in each dimension. Currently cell must be orthorhombic. defaults to current simulation cell

driver(type, **kwargs)

Initialize driver of OpenFTS object. See elsewhere in documentation for description of args.

field_layout(npw, random_seed)

Initialize field_layout of OpenFTS object. See elsewhere in documentation for description of args.

field_updater(type, **kwargs)

Initialize field_updater of OpenFTS object. See elsewhere in documentation for description of args.

get_cell_tensor()

query localfts object and return cell tensor (in Rg3 units)

get_cell_volume()

query localfts object and return cell volume (in Rg3 units)

get_field_float_type()

query localfts object and return field_float_type as string

get_min_smearing_length()

query localfts object and return minimum smearing length (in Rg3 units)

get_model_Rgref()

query localfts object and return Rg of reference chain (using bref and Nref)

get_model_exchange_to_species_map()

query localfts object and return exchange to species field mapping as matrix

get_model_nfields()

query localfts object and return number of fields used in model

get_molecule_alpha(imol)

query localfts object and return alpha of specified molecule

get_molecule_ncopies(imol)

query localfts object and return ncopies of specified molecule

get_runtime_mode()

Get the runtime mode of the OpenFTS object.

init_fields_from_file(filename, field_type='exchange')

Initialize model fields from a file.

Parameters:
  • file – filename to read in. Must contain same number of fields as expected by model.

  • field_type – types of fields to be read in. Options are exchange or species

init_model_field(fieldname, type, **kwargs)

Initialize model of OpenFTS object. See elsewhere in documentation for description of args.

Parameters:

fieldname – Name of field to initialize. This depends on model (e.g. mu_minus, mu_plus, mu_3).

initialize(logfile=None)

Initialize the C++ OpenFTS backend but do not run. Useful to query the fts object, but dont want to run a simulation.

Args:

logfile: redirect stdout to logfile

io_get_field_error()

Read field_error_total from final step of a completed run

io_get_scalar_operator(key, mode='final')

Read a scalar operator from final step of a completed run. Uses utils.get_scalar_operator() function

Parameters:

key – key to read from operators.dat file (or similar). See top line of file for options.

io_get_status()

Read the STATUS of a completed run

map_to_particle(**kwargs)

Function that takes current FTS values and writes the corresponding particle-based input files

model(type, **kwargs)

Initialize model of OpenFTS object. See elsewhere in documentation for description of args.

output_default()

Set the output files written by OpenFTS to the defaults. Currently, this is the only option.

run(logfile=None)

Run the OpenFTS module. Imports and calls the C++ backend via pybind11.

Args:

logfile: redirect stdout to logfile

runtime_mode(mode)

Set the runtime mode of the fts run.

Parameters:

mode – Mode of run. Possible options are serial or gpu

runtime_precision(precision)

Set the runtime floating point precision of the fts run.

Parameters:

precision – Floating point precision of run. Possible options are double, single or unspecified

variable_cell(**kwargs)

Initialize variable_cell of OpenFTS object. See elsewhere in documentation for description of args.

write_json(filename)

Write fts arguments to a json file. Useful for running directly using C++ executable.

openfts.get_scalar_operators(fname, mode)

read from fname and convert all data into a dictionary This is the updated version. The old version was mostly a wrapper around get_scalar_operator()

Args:

filename: fts object or name of file to read. Typically operators.dat mode: parsing mode. Options are ‘timeseries’, ‘final’, ‘average’ or ‘smart_average’

Returns:

operators: a dictionary where each operator is stored under a key

openfts.get_scalar_operator(fname, key, mode)
read from filename to get operator named ‘key’

this function is very similar to openfts.io_get_scalar_operator In fact, I could probably overload this function to either take a openfts object or a filename as the first argument

Args:

filename: fts object or name of file to read. Typically operators.dat key: key to read from operators.dat file (or similar). See top line of file for options. mode: parsing mode. Options are ‘timeseries’, ‘final’, ‘average’

Returns:

operator: either a scalar or a np.array depending on mode