v6.0.0 docs — cloud-only, subscription (fullrmc.com). Free download: v4.1.1.

fullrmc.Engine module

Engine is fullrmc’s main module. It contains ‘Engine’ the main class of fullrmc which is the stochastic artist. The engine main atomic structure input file format is the Protein Data Bank (PDB), ‘.pdb’ . A PDB file is chosen because of its flexible to define atomic and molecular structure. In addition to a PDB file, fullrmc’s engine can also consume .cif and .xyz files to set the initial atomic structure using respectively ‘read_cif_set_pdb’ and ‘read_xyz_set_pdb’ engine methods. Also, one can use ‘build_crystal_set_pdb’ engine method as another method to set the initial pdb structure using a set of crystallographic information. fullrmc’s Engine is built to handle many experimental data while controlling the evolution of the system using user-defined molecular and atomistic constraints such as bond-length, bond-angles, dihedral angles, atomic/molecular-distances, etc.

fullrmc.Engine.generate_random_float()

random() -> x in the interval [0, 1).

class fullrmc.Engine.BackwardCompatibility

Bases: object

This is a versions adapter to insure some backward compatibility of fullrmc’s engines. It’s used to make sure old version engines are loadable in newer versions.

classmethod add_missing(repo, frame, obj, engine)

Add repository entries that are missing from an older, already-saved engine or constraint object because they were introduced in a newer fullrmc version. This keeps engines saved with an older fullrmc version loadable in newer versions without losing or breaking their state.

Parameters:
  1. repo (pyrep.Repository): The engine’s repository instance.

  2. frame (string): The frame being loaded.

  3. obj (Engine, Constraint): The engine or constraint instance to check and patch for missing data.

  4. engine (Engine): The engine instance being loaded.

classmethod normalize(repo, frame, obj, engine)

Normalize an older, already-saved engine’s internal repository layout and multiframe structure metadata so it matches what the current fullrmc version expects (e.g. renaming legacy internal attribute names, backfilling the optimizations lookup table, and fixing up multiframe experimental constraints parameters).

Parameters:
  1. repo (pyrep.Repository): The engine’s repository instance.

  2. frame (string): The frame being loaded.

  3. obj (Engine, Constraint): The engine or constraint instance to normalize.

  4. engine (Engine): The engine instance being loaded.

class fullrmc.Engine.InterceptHook(path, password=None)

Bases: object

Engine runtime intercept hook. This can be used by a thread or another process to intercept a running stochastic engine to do different actions such as stop, save, export a pdb file or reset the standard error.

Calling InterceptHook methods on a non-running engine will be ignored.

Parameters:
  1. path (string): Engine repository path

  2. password (string): Engine repository password. If None, default value will be given hoping that the running engine repository password is also the default one. Otherwise the hook connection will fail.

From a different python process, run the following code to handle a hook of a running engine.

# import fullrmc's InterceptHook
from fullrmc import InterceptHook

# create hook
hook = InterceptHook(path='my_engine.stc')

# safely force stopping running engine
hook.stop_engine()

# safely force saving running engine
hook.save_engine()

# safely export a pdb file of the current engine structure status
hook.export_pdb()

# safely reset standard error during engine runtime
hook.reset_standard_error()
stop_engine()

Stop a running engine

stop_builder()

Stop a running builder

save_engine()

Force saving a running engine

export_pdb()

Export a pdb of the current state of a running engine

reset_standard_error()

Reset a running engine total standard error

classmethod get_engine_hook(engine)

Get engine instance intercept hook

classmethod clear(engine)

Release all unexecuted hooks from engine

class fullrmc.Engine.Engine(path=None, logKwargs=None, freshStart=False, timeout=20, password=None)

Bases: object

fullrmc’s engine, is used to launch a stochastic modelling which is different from traditional Reverse Monte Carlo (RMC). It has the capability to use and fit simultaneously multiple sets of experimental data. One can also define constraints such as distances, bonds length, angles and many others.

Parameters:
  1. path (None, string): Engine repository (directory) path to save the engine. If None is given path will be set when saving the engine using Engine.save method. If a non-empty directory is found at the given path an error will be raised unless freshStart flag attribute is set to True.

  2. logKwargs (None, dict): Logging kwargs dictionary. This will be used to update Globals.LOGGER using update method

  3. freshStart (boolean): Whether to remove any existing fullrmc engine at the given path if found. If set to False, an error will be raise if a fullrmc engine or a non-empty directory is found at the given path.

  4. timeout (number): The maximum delay or time allowed to successfully set the lock upon reading or writing the engine repository

  5. password (None, string): Engine repository password. If None, default value will be given.

# import engine
from fullrmc.Engine import Engine

# create engine
ENGINE = Engine(path='my_engine.stc')

# set pdb file
ENGINE.set_pdb(pdbFileName)

# Add constraints ...
# Re-define groups if needed ...
# Re-define groups selector if needed ...
# Re-define moves generators if needed ...

# save engine
ENGINE.save()

# run engine for 10000 steps and save only at the end
ENGINE.run(numberOfSteps=10000, saveFrequency=10000)
classmethod build_engine_from_snapshot(snapshot, enginePath, replace=False)

Create engine given a snapshot

Parameters:
  1. snapshot (string, list): snapshot file path given as a string or the list of snapshot file lines

  2. enginePath (string): Engine file path to save.

  3. replace (boolean): whether to replace engine if found at given or derived enginePath

Returns:
  1. engine (fullrmc.Engine.Engine): the built engine instance

# import engine
from fullrmc.Engine import Engine

# build engine from snapshot
ENGINE = Engine.build_engine_from_snapshot(snapshot="my_engine.snapshot", enginePath="my_engine")
create_frame_from_optimizer(frame, optEngine, confName=None, supercell=None, contiguous=True, optimizedStructure=True, addExperimentalConstraint=True, addRigidConstraints=True)

Create multiframe with one subframe from given optimization

Parameters:
  1. frame (None, str): the name of the multiframe to add. If engine is empty, frame ‘0’ will be used automatically used

  2. optEngine (fullrmc.Engine): the fullrmc engine containing the optimization

  3. confName (None, str): the optimization configuration name in optimization engine. If None, used optimization will be used or if a single optimization is defined, it will be used automatically

  4. supercell (None, list): The supercell size. If None, optimization supercell will be used

  5. contiguous (bool): whether to create structure from contiguous optimized structure

  6. optimizedStructure (bool): whether to used optimized structure or initially set one

  7. addExperimentalConstraint (bool): whether to add optimization experimental constraints to stochastic engine

  8. addRigidConstraints (bool): whether to add optimization rigid constraints to stochastic engine

  9. **eKwargs: stochastic engine instantiation kwargs

Returns:
  1. engine (fullrmc.Engine): the same engine instance (self), returned for chaining, now containing the newly created frame

build_engine_from_optimizer(path, optEngine, confName=None, supercell=None, contiguous=True, optimizedStructure=True, addExperimentalConstraint=True, addRigidConstraints=True, **eKwargs)

Create a stochastic engine from an optimizer configuration. Optimization structure and constraints will be set to frame ‘0’

Parameters:
  1. path (string): Directory path to save the engine.

  2. optEngine (fullrmc.Engine): the fullrmc engine containing the optimization

  3. confName (None, str): the optimization configuration name in optimization engine. If None, used optimization will be used or if a single optimization is defined, it will be used automatically

  4. supercell (None, list): The supercell size. If None, optimization supercell will be used

  5. contiguous (bool): whether to create structure from contiguous optimized structure

  6. optimizedStructure (bool): whether to used optimized structure or initially set one

  7. addExperimentalConstraint (bool): whether to add optimization experimental constraints to stochastic engine

  8. addRigidConstraints (bool): whether to add optimization rigid constraints to stochastic engine

  9. **eKwargs: stochastic engine instantiation kwargs

Returns:
  1. engine (fullrmc.Engine): created fullrmc stochastic engine

create_snapshot(filePath, frames=None, description=None, replace=False)

Create a snapshot of engine that can be used to export engine to fullrmc on the cloud

Parameters:
  1. filePath (str): file path to export blocks to

  2. frames (None, list): list of frames to create the snapshot. If None, all engine frames will be considered

  3. description (None, string, list): description to include in header

  4. replace (boolean): whether to replace existing engine snapshot

ENGINE.create_snapshot(filePath="my_engine.snapshot")
export_snapshot(*args, **kwargs)

Alias to create_snapshot

codify(export='codified_engine.py', name='ENGINE', engineSaveName='engine.stc', frames=None, addDependencies=True)

Codify engine full state to a code that once executed it will regenerate and save the engine on disk. This is a better alternative to transferring engine from one system to another. The generated code is python 2 and 3 compatible and operating system safe allowing to get an executable code to regenerate the engine.

Parameters:
  1. export (None, str): file to write generated codified engine code. If string is given, it’s the file path

  2. name (str): engine variable name in the generate code

  3. engineSaveName (None,str): directory path to save engine upon executing the codified engine code

  4. frames (None, str, list): the list of frames to codify. At least one traditional frame must be given. If None, all frames will be codified.

  5. addDependencies (bool): whether to add imports dependencies to the generated code header. Dependencies will always be added to the code header in the exported file.

Returns:
  1. dependencies (list): list of dependencies import strings

  2. code (str): the codified engine code

property repository

The engine’s pyrep.Repository instance used for saving and loading. None if the engine has not been saved yet.

property locker

The engine repository’s locker instance used for concurrent-access locking. None if the engine has not been saved yet.

property multiframeStructure

Used frame multiframe meta-structure definition.

property password

Engine repository password.

property path

The stochastic engine repository path if set or saved.

property name

The stochastic engine repository directory name.

property version

The stochastic engine version.

property id

The stochastic engine id.

property info

The stochastic engine information (version, id) tuple.

property frames

The stochastic engine frames dictionary copy.

property multiframes

The stochastic engine multiframes name.

property traditionalFrames

The stochastic engine traditional frames name.

property framesPath

The stochastic engine list of traditional frames name and multiframes path.

property usedFrame

The stochastic engine frame in use.

property lastSelectedGroupIndex

The stochastic engine last moved group instance index in groups list.

property lastSelectedGroup

The stochastic engine last moved group instance.

property lastSelectedAtomsIndex

The stochastic engine last moved atoms index.

property state

The stochastic engine state.

property generated

Number of generated moves.

property removed

Removed atoms tuple (tried, accepted, ratio)

property tried

Number of tried moves.

property accepted

Number of accepted moves.

property tolerated

Number of tolerated steps in spite of increasing totalStandardError

property tolerance

Tolerance in percent.

property groups

The stochastic engine defined groups list.

property pdb

The stochastic engine pdbparser instance.

property supercell

The structure supercell attribute. If set, it’s a list of unitcells dictionaries where keys are atom ‘indexes’ in the unitcell, unitcell ‘position’ in the supercell and the list of 26 first unitcells ‘neighbours’ for the unitcell.

property allChainIdentifiers

Atoms chain identifiers list

property chainIdentifiers

Sorted set of all existing atom chain identifiers.

property numberOfChainIdentifiers

Length of atoms chain identifiers set.

property numberOfAtomsPerChainIdentifier

Number of atoms per chain identifier dictionary.

property allSegments

Atoms Segments list

property segments

Sorted set of all existing atom segments.

property numberOfSegments

Length of atoms segments set.

property numberOfAtomsPerSegment

Number of atoms per segment dictionary.

property allSequences

Atoms Sequences list

property sequences

Sorted set of all existing atom sequences.

property numberOfSequences

Length of atoms sequences set.

property numberOfAtomsPerSequence

Number of atoms per sequence dictionary.

property allResidues

Atoms residues list

property residues

Sorted set of all existing atom residues.

property numberOfResidues

Length of atoms residues set.

property numberOfAtomsPerResidue

Number of atoms per residue dictionary.

property boundaryConditions

Engine’s boundaryConditions instance.

property isPBC

Whether boundaryConditions are periodic.

property isIBC

Whether boundaryConditions are infinte.

property basisVectors

The boundary conditions basis vectors in case of PeriodicBoundaries, None in case of InfiniteBoundaries.

property maximumLength

Maximum length that the structure can get to before running into periodic boundary conditions atomic images

property reciprocalBasisVectors

The boundary conditions reciprocal basis vectors in case of PeriodicBoundaries, None in case of InfiniteBoundaries.

property volume

The boundary conditions basis volume in case of PeriodicBoundaries, None in case of InfiniteBoundaries.

property realCoordinates

The real coordinates of the current configuration.

property boxCoordinates

The box coordinates of the current configuration in case of PeriodicBoundaries. Similar to realCoordinates in case of InfiniteBoundaries.

property numberOfMolecules

Number of molecules.

property moleculesIndex

Atoms molecule index numpy array.

property moleculesName

Atoms molecule name list.

property elementsIndex

Atoms element index numpy array indexing elements sorted set.

property elements

Sorted set of all existing atom elements.

property allElements

Atoms element list.

property namesIndex

Atoms name index numpy array indexing names sorted set

property names

Sorted set of all existing atom names.

property allNames

Atoms name list.

property numberOfNames

Length of atoms name set.

property numberOfAtoms

Number of atoms in the pdb.

property numberOfAtomsPerName

Number of atoms per name dictionary.

property numberOfElements

Number of different elements in the pdb.

property numberOfAtomsPerElement

Number of atoms per element dictionary.

property numberDensity

System’s number density computed as \(\rho_{0}=\frac{N}{V}\) where N is the total number of atoms and V the volume of the system.

property constraints

Copy list of all constraints instances.

property groupSelector

Engine’s group selector instance.

property totalStandardError

Engine’s last recorded totalStandardError of the current configuration.

property lossFunction

Engine’s experimental constraints loss function

property timeout

Timeout to successfully acquire the lock upon reading or writing to the repository

property molecules

Get molecules dictionary where keys are molecule names and values are dictionaries where keys are molecules index and values are ‘atoms_index’, ‘atoms_name’ and ‘atoms_element’ of the atoms in the molecule.

property moleculesElementSummary

Get a list of molecules (name,element_composition,occurrence) triplets

property moleculesNameSummary

Get a list of molecules (name,name_composition,occurrence) triplets

property moleculesSummary

Get a list of molecules (name,element_composition,name_composition,occurrence) quadruplets

property availableDFTs

Get engine available dft engines

property optimizations

Get engine available optimization structures

property optimizer

Get engine crystal optimizer instance if instanciated

property dftEngine

Get fullrmc engine Density-Functional Theory Engine

property optimizerSolver

Get engine crystal optimizer solver instance if instanciated

start_espresso_engine(executablesDir=None, pseudoDir=None, _log=True)

Start quantum-espresso dft engine

Parameters:
  1. executablesDir (None, string): quantum-espresso executables path. If None, ‘~/quantum_espresso/qe/bin’ will be used

  2. pseudoDir (None, string): quantum-espresso pseudo-potential files

    path. If None, ‘~/quantum_espresso/pseudo’ will be used

set_timeout(timeout)

Set repository access timeout

Parameters:
  1. timeout (number): The maximum delay or time allowed to successfully set the lock upon reading or writing the engine repository

get_multiframe_metadata(frame=None, original=False)

Get multiframe structure metadata

Parameters:
  1. frame (None, string): multiframe of subframe name. If None is given, used frame will be used. An error will be raised if given frame is not a subframe or a multiframe

  2. original (boolean): whether to get metadata of current structure state or original as set

Returns:
  1. metadata (dict): multiframe original structure metadata dictionary

get_multiframe_structure(frame=None, pull=False)

Get multiframe structure type given a frame.

Parameters:
  1. frame (None, string): multiframe name. If None, used frame will be used. Given frame must be a multiframe or a subframe

  2. pull (boolean): whether to force pulling multiframe structure from repository

Returns:
  1. structure (dict): multiframe meta-structure dictionary

get_frame_supercell(frame=None, pull=False)

The structure supercell attribute. Unlike Engine.supercell property, this method is fullrmc version compatible that reconstructs missing unitcell properties.

Parameters:
  1. frame (None, string): multiframe name. If None, used frame will be used. Given frame must be a multiframe or a subframe

  2. pull (boolean): whether to force pulling multiframe structure from repository

Returns:
  1. supercell (None, dict): supercell structure. If frame structure is not a supercell, None is returned.

set_multiframe_structure(structure=None, frame=None, _logSuccess=True)

Set multiframe structure as statistical, nanoscopic or mesoscopic. If nanoscopic structure is given, frames actual boundary conditions and number density will be updated calling set_boundary_conditions.

When nanoscopic, ‘_shapeFuncParams’ will be automatically adjusted for all relevant constraints in multiframeStructure[‘experimental_constraints’]

N.B. for density reasons, only infinite boundary conditions are allowed for nanoscopic computation. PeriodicBoundaries are implemented but an exception will be raised if set so.

Parameters:
  1. structure (None, dict, string): structure data dictionary. If None, statistical will be set automatically. If string is given, then ‘statistical’ and ‘mesoscopic’ is accepted. Otherwise a dictionary must be given including ‘type’ key along with other needed information

  2. frame (None, string): multiframe to set structure. If None, used frame will be used. Given frame must be a multiframe or a subframe

Returns:
  1. structure (dict): the multiframe structure

from fullrmc.Globals import WATER_NUMBER_DENSITY

structure = {'type':'nanoscopic', 'boundaryConditions':None,
             'numberDensity':WATER_NUMBER_DENSITY,
             'grainSize':{None:3, 'h':5},
             'subframe_reference':'multi/0'}
ENGINE.set_multiframe_structure(structure=structure, frame='multi')
multiframe_structure_set_grain_size(grainSize, frame=None)

Set grain size for multiframe structure.

Parameters:
  1. grainSize (number, dict):

  2. frame (None, string): multiframe to set structure. If None, used frame will be used. Given frame must be a multiframe or a subframe

Returns:
  1. structure (dict): the multiframe structure

multiframe_structure_reset_constraints(frame=None)

Reset multiframe structure. This will simply update constraints parameters across if necessary

Parameters:
  1. frame (None, string): multiframe to set structure. If None, used frame will be used. Given frame must be a multiframe or a subframe

Returns:
  1. structure (dict): the multiframe structure

multiframe_structure_reset(frame=None)

Reset multiframe structure by calling Engine.set_multiframe_structure using the given frame structure. This will ensure resetting the multiframe structure metadata as well as all constraints

Parameters:
  1. frame (None, string): multiframe to set structure. If None, used frame will be used. Given frame must be a multiframe or a subframe

Returns:
  1. structure (dict): the multiframe structure

get_original_data(name, frame=None)

Get original data as initialized and parsed from pdb.

Parameters:
  1. name (string): Data name.

  2. frame (None, string): get original data of a particular frame. If None, engine used frame will be used

Returns:
  1. value (object): Data value

is_engine(path, repo=False, mes=False, safeMode=True)

Get whether a fullrmc engine is stored in the given path.

Parameters:
  1. path (string): The path to fetch.

  2. repo (boolean): Whether to return repository if an engine is found. Otherwise None is returned.

  3. mes (boolean): Whether to return explanatory message.

  4. safeMode (boolean): whether to acquire the lock upon loading. This is not necessary unless another process is writing to the repository at the same time.

Returns:
  1. result (boolean): The fetch result, True if engine is found False otherwise.

  2. repo (pyrep.Repository): The repository instance. This is returned only if ‘repo’ argument is set to True.

  3. message (string): The explanatory message. This is returned only if ‘mes’ argument is set to True.

save(path=None, copyFrames=True)

Save engine to disk.

Parameters:
  1. path (None, string): Repository path to save the engine. If path is None, engine’s path will be used. If path and engine’s path are both None, and error will be raised.

  2. copyFrames (boolean): If path is None, this argument is discarded. This argument sets whether to copy all frames data to the new repository path. If path is not None and this argument is False, Only used frame data will be copied and other frames will be discarded in new engine.

N.B. If path is given, it will automatically update engine’s path to point towards given path.

classmethod load(path, safeMode=True)

Load and return engine instance. None of the current engine attribute will be updated. Must be used as the following:

# import engine
from fullrmc.Engine import Engine

# load an existing engine
ENGINE = Engine.load(path)
Parameters:
  1. path (string): Directory path to save the engine.

  2. safeMode (boolean): whether to acquire the lock upon loading. This is not necessary unless another process is writing to the repository at the same time.

Returns:
  1. engine (Engine): Engine instance.

set_log_file(logFile)

Set the log file basename.

Parameters:
  1. logFile (None, string): Logging file basename. A logging file full name will be the given logFile appended ‘.log’ extension automatically.

is_frame(frame)

Check whether a given frame exists.

Parameters:
  1. frame (string): Frame name.

Returns:
  1. result (boolean): True if frame exists False otherwise.

add_frames(frames, create=False, _addConstraints=True, _log=True)

Add a one or many (multi)frame to engine. Pdb structure must be set before adding any frame

Parameters:
  1. frames (string, dict, list): It can be a string to add a single frame, a dictionary to add a single multiframe or a list of strings and/or dictionaries to add multiple (multi)frames.

  2. create (boolean): adding a frame to engine doesn’t create the frame data in the stochastic engine repository. Frames data are created once frame is used. Setting create to True, forces creating the repository data by copying used frame ones. If used frame is not a traditional frame, create will get automatically reset to False

add_frame(*args, **kwargs)

Alias to add_frames

add_subframes(multiframe, subframes)

Add a one or many subframes to an existing multiframe. If multiframe data are already created, the subframes data will be automatically copied from the last subframe of the multiframe

Parameters:
  1. multiframe (string): multiframe name to add subframes to

  2. subframes (string, int, list): subframe name or number of subframes to add or a list of subframes name

add_subframe(*args, **kwargs)

Alias to add_subframes

reinit_frame(frame)

Reset frame data to initial pdb coordinates.

Parameters:
  1. frame (string): The frame name to set.

get_frame_category(frame)

Get whether a given frame name is a normal frame or a multiframe or a multiframe subframe. If frame does not exist an error will be raised.

Parameters:
  1. frame (string): Frame name or repository relative path

Returns:
  1. isNormalFrame (boolean): Whether it’s a normal single frame

  2. isMultiframe (boolean): Whether it’s a multiframe

  3. isSubframe (boolean): Whether it’s a multiframe subframe path

reload_frame()

Reload used frame data from repository. This is nothing else but an alias to ‘Engine.set_used_frame’ with frame set to currently used frame and reload flag set to True

set_used_frame(frame, reload=False, _addConstraints=True, _updateRepo=True, _log=True)

Change engine used frame.

Parameters:
  1. frame (string): The frame to switch to and use from now on.

  2. reload (boolean): Whether to reload frame if currently used frame is the same as given frame to load

  3. _updateRepo (boolean): whether to update repository usedFrame value. Meant to be used internally.

duplicate_frame(frame, name, _log=True)

Create new frame by duplicating an already existing one. The duplicated frame must be defined and existing on disk. If duplicated frame is a subframe existing on disk is not a requirement.

Parameters:
  1. frame (string): name of the frame that needs to be duplicated

  2. name (string): frame new name to create the duplicate

clone_frame(cloneFrom, cloneTo)

Clone frame data one to another. The frame cloning data to (cloneTo) will become an exact copy of the frame cloning data from (cloneFrom)

Parameters:
  1. cloneFrom (string): the frame to clone data from

  2. cloneTo (String): the frame to clone data to

use_frame(*args, **kwargs)

Alias to set_used_frame.

delete_frame(frame)

Delete frame data from Engine as well as from repository .

Parameters:
  1. frame (string): The frame to delete.

rename_frame(frame, newName)

Rename (multi)frame. All frames can be renamed except for frame 0

Parameters:
  1. frame (string): The frame to rename.

  2. newName (string): The new name.

get_pdb(foldIntoBox=False, contiguous=False, frame=None, split=False, _listNonNanoscopic=False, _foldSupercell=False, _mergeResolution=None)

Get a pdb instance of the last refined and save configuration state.

Parameters:
  1. foldIntoBox (boolean): Whether to fold all atoms into PeriodicBoundaries box. If boundary conditions are InfiniteBoundaries then nothing will be done.

  2. contiguous (boolean): Whether to build contiguous molecules using PeriodicBoundaries box. If boundary conditions are InfiniteBoundaries then nothing will be done.

  3. frame (None, string): Target frame name. If None, engine used frame is used. If multiframe is given, the multiframe structure must be defined as nanoscopic otherwise an error will be raised

  4. split (Boolean): whether to force split multiframe into multiple structures.

Returns:
  1. pdb (pdbparser, list): The pdb instance of a list pdb instances.

export_xyz(path, foldIntoBox=False, contiguous=False, frame=None, split=False, _foldSupercell=False, _mergeResolution=None)

Export a xyz file of the last refined and saved configuration state.

Parameters:
  1. path (None, string): the xyz file path. If None then xyz string format is returned

  2. foldIntoBox (boolean): Whether to fold all atoms into PeriodicBoundaries box. If boundary conditions are InfiniteBoundaries then nothing will be done.

  3. contiguous (boolean): Whether to build contiguous molecules using PeriodicBoundaries box. If boundary conditions are InfiniteBoundaries then nothing will be done.

  4. frame (None, string): Target frame name. If None, engine used frame is used. If multiframe is given, the multiframe structure must be defined as nanoscopic otherwise an error will be raised

  5. split (Boolean): whether to force split multiframe into multiple structures. This will result in creating a zip file of all of those if path is not None.

Returns:
  1. content (None, str, list): If path is string then None is returned otherwise the xyz file as a string or a list of those will be returned

export_cif(path, foldIntoBox=False, contiguous=False, frame=None, split=False, _foldSupercell=False, _mergeResolution=None)

Export a cif file of the last refined and saved configuration state.

Parameters:
  1. path (None, string): the cif file path. If None then cif string format is returned

  2. foldIntoBox (boolean): Whether to fold all atoms into PeriodicBoundaries box. If boundary conditions are InfiniteBoundaries then nothing will be done.

  3. contiguous (boolean): Whether to build contiguous molecules using PeriodicBoundaries box. If boundary conditions are InfiniteBoundaries then nothing will be done.

  4. frame (None, string): Target frame name. If None, engine used frame is used. If multiframe is given, the multiframe structure must be defined as nanoscopic otherwise an error will be raised

  5. split (Boolean): whether to force split multiframe into multiple structures. This will result in creating a zip file of all of those if path is not None.

Returns:
  1. content (None, str, list): If path is string then None is returned otherwise the cif file as a string or a list of those will be returned

export_pdb(path, foldIntoBox=False, contiguous=False, frame=None, split=False, _foldSupercell=False, _mergeResolution=None)

Export a pdb file of the last refined and saved configuration state.

Parameters:
  1. path (None, string): the pdb file path. If None then pdb string format is returned

  2. foldIntoBox (boolean): Whether to fold all atoms into PeriodicBoundaries box. If boundary conditions are InfiniteBoundaries then nothing will be done.

  3. contiguous (boolean): Whether to build contiguous molecules using PeriodicBoundaries box. If boundary conditions are InfiniteBoundaries then nothing will be done.

  4. frame (None, string): Target frame name. If None, engine used frame is used. If multiframe is given, the multiframe structure must be defined as nanoscopic otherwise an error will be raised

  5. split (Boolean): whether to force split multiframe into multiple structures. This will result in creating a zip file of all of those if path is not None.

Returns:
  1. content (None, str, list): If path is string then None is returned otherwise the pdb file as a string or a list of those will be returned

set_loss_function(loss='se', agg='sum', warping=False, frame=None, _stopPropagation=False, _log=True)

Set experimental constraints loss function to use during stochastic engine runtime.

Parameters:
  1. loss (str, dict): the loss function name. Known losses names are

    • ae: Absolute Error defined as \(\Omega_{i}W_{i}\left|\Delta_{i}\right|\)

    • se: Squared Error defined as \(\Omega_{i}W_{i}(\Delta_{i})^{2}\)

    • rae: Relative Absolute Error defined as \(\Omega_{i}W_{i}\frac{\left|\Delta_{i}\right|}{S(1/(10^{-3}+\left|D_{i}\right|))}\)

    • rse: Relative Squared Error defined as \(\Omega_{i}W_{i}\frac{\Delta_{i}^{2}}{S(1/(10^{-3}+\left|D_{i}\right|))}\)

    • lae: Log Absolute Error defined as \(\Omega_{i}W_{i}Ln(1+\left|\Delta_{i}\right|)\)

    • lse: Log Squared Error defined as \(\Omega_{i}W_{i}Ln((1+(\Delta_{i})^{2})\)

    • peaks: Peaks Biased Error defined as \(\Omega_{i}W_{i} \left( \left|D_{i}\right|-min(\left|D_{i}\right|)+1 \right) \left|\Delta_{i}\right|\)

    • welsch: function defined as \(\Omega_{i}Ln\left(\frac{1}{2}(\frac{\left|\Delta_{i}\right|}{c})^{2}+1\right)\)

    • cauchy: function defined as \(\Omega_{i}\left(1-e^{-\frac{1}{2}(\frac{\left|\Delta_{i}\right|}{c})^{2}}\right)\)

    • adjustable: function defined as \(\Omega_{i}\frac{|\alpha-2|}{\alpha}\left((\frac{(\frac{\left|\Delta_{i}\right|}{c})^{2}}{|\alpha-2|}+1)^{\frac{\alpha}{2}}-1\right)\) Special cases for adaptive loss are when \(\alpha\) is set to 0 ‘adaptive’ loss will be equal to ‘cauchy’; when \(\alpha\) is set to 2 ‘adaptive’ loss will be similar to ‘se’ \(\frac{\left|\alpha-2\right|}{\alpha} \left(\frac{\left|\Delta_{i}\right|}{c} \right)^{2}\); when \(\alpha\) approches \(-\infty\) ‘adaptive’ approaches ‘welsch’

    • smart-uniformize: this is a machine learning based loss implementation that will optimize the loss function hyper-curvature by attempting to uniformize the absolute relative error probability distribution. Learning will happen every ‘update’ stochastic engine accepted step and by a ‘learning_rate factor up to a ‘clipping’ value. Allowed parameters are ‘learning_rate’, ‘clipping’ and ‘update’

Where:
  • \(E_{i}\): experimental data at point \(i\)

  • \(M_{i}\): model data at point \(i\)

  • \(\Delta_{i}=E_{i}-M_{i}\): the difference between the experimental data and model at point \(i\)

  • \(<E>\): the experimental data mean

  • \(D_{i}=E_{i}-<E>\): the difference between experimental data at point \(i\) and the global mean

  • \(S\): sigmoid function defined as \(S(x)=\frac{1}{1+e^{-x}}\)

  • \(\Omega_{i}\): loss warping added at point \(i\). This is set using the ‘warping’ parameter

  • \(W_{i}\): error weight at point \(i\). This weight is set using ‘constraint.set_data_weight’ method. By default it’s None

  • \(Ln\): natural logarithm function

  1. agg (string): set how to aggregate the computed point loss. It can be ‘sum’ for \(\sum \limits_{i}^{N} loss_{i}\) or ‘mean’ for \(\frac{\sum \limits_{i}^{N} loss_{i}}{N}\). Here \(N\) is total number of experimental data point used within the user set limits and \(loss_{i}\) is the computed loss at point ‘\(i\)

  2. warping (None, boolean, integer, float, dict): Whether to create loss warping to the loss function upon stochastic engine runtime. Warping will help the engine getting out of local minima without jeopardizing the quality of the atomic model.

    If False or None is given, no warping will be created.

    If True is given, then random warping will be created at an update frequency of 1000 generated step with a maximum intensity of 0.5 standard deviation.

    If integer is given, it will be considered the update frequency of random warping.

    If float is given, it will be considered the maximum standard deviation intensity of random warping.

    If a dict is given, it can contain the following keys ‘type’ for the different types of allowed warping (default ‘random’); ‘update’ for update frequency (default 1000); ‘intensity’ for maximum standard deviation ratio (default 0.5).

  3. frame (None, string): Target frame name. If None, engine used frame is used.

# import engine
from fullrmc.Engine import Engine

# create engine
ENGINE = Engine(path='my_engine.stc')

# set pdb file
ENGINE.set_pdb(pdbFileName)

# Add constraints ...

# Add multiframe 'size_distribution' ...

# Set loss function for frame 0
ENGINE.set_loss_function(loss={'name':'adjustable', 'alpha':0.5, 'c':1}, frame='0')

# Set loss function for all multiframe 'size_distribution' subframes
ENGINE.set_loss_function(loss='welsch', agg='sum', warping={'type':'random', 'update':100, 'intensity':0.5}, frame='size_distribution')
reset_loss_data(frame=None)

Resets loss function runtime data

Parameters:
  1. frame (None, string): Target frame name. If None, engine used frame is used.

set_tolerance(tolerance, frame=None)

Set engine’s runtime tolerance value.

Parameters:
  1. tolerance (number): The runtime tolerance parameters. It’s the percentage [0,100] of allowed unsatisfactory ‘tried’ moves.

  2. frame (None, string): Target frame name. If None, engine used frame is used.

set_group_selector(selector, frame=None)

Set engine’s group selector instance.

Parameters:
  1. selector (None, GroupSelector): The GroupSelector instance. If None is given, RandomSelector is set automatically.

  2. frame (None, string): Target frame name. If None, engine used frame is used.

dump_groups_updated()

This will save groups to repository. Must be called after altering groups properties such as setting a new move generator.

clear_groups()

Clear all engine’s defined groups.

remove_groups(groups)

Remove groups by instance, name or index

Parameters:
  1. groups (integer, string, Group, list): groups to remove, this can be a specific group index, or a group name or a group instance or a list of all of those

add_group(g, name=None, subsettingSize=None, subsettingType='random', _check=True)

Add a group to engine’s groups list.

Parameters:
  1. g (Group, integer, list, set, tuple numpy.ndarray): Group instance, integer, list, tuple, set or numpy.ndarray of atoms index.

  2. name (None, string): group name. If g is a Group instance, Group.set_name will be called if given name is not None. If g is not a Group instance and name is None it will automatically changed to ‘group’.

  3. subsettingSize (None, int,float,tuple): If None, no subsetting will be created. If given, all groups if given as indexes will set as subset groups otherwise groups given as groups instances won’t be touched

  4. subsettingType (string): it can be ‘random’ for RandomSubsetGroup or ‘centered’ for CenteredSubsetGroup

  5. _check (boolean): meant to be used internally

set_groups(groups, name='group', subsettingSize=None, subsettingType='random', add=False, _check=True)

Set engine’s groups.

Parameters:
  1. groups (None, Group, list): A single Group instance or a list, tuple, set of any of Group instance, integer, list, set, tuple or numpy.ndarray of atoms index that will be set one by one by set_group method. If None is given, single atom groups of all atoms will be all automatically created which is the same as using set_groups_as_atoms method.

  2. name (None, string, list): groups name. If string is given, the same name will be given to all groups. If list is given, it must have the same length as the number of given groups

  3. subsettingSize (None, int,float,tuple): If None, no subsetting will be created. If given, all groups if given as indexes will set as subset groups otherwise groups given as groups instances won’t be touched

  4. subsettingType (string): it can be ‘random’ for RandomSubsetGroup or ‘centered’ for CenteredSubsetGroup

  5. add (boolean): whether to add newly generated groups to old ones

  6. _check (boolean): meant to be used internally

build_groups(filter=None, groupBy=('residue', 'sequence', 'segment'), name=None, subsettingSize=None, subsettingType='random', add=False, _evaluator=None, _raiseNoGroupsCreated=False)

Build groups given a list of groupBy keywords and a filter expression

Parameters:
  1. filter (None, string): filter expression string that will be evaluated to select the atoms to consider while building the groups. Expression can ingest all python math mathematical functions and constants along with all of engine atoms ‘index’, ‘residue’,’sequence’, ‘segment’,’chainIdentifier’,’element’, ‘name’, ‘x’, ‘y’, ‘z’, ‘moleculeIndex’, ‘moleculeName’ attributes. If None is given, all atoms are considered.

  2. groupBy (None, string, list): List of group by keywords to create atoms grouping. If None is given, all remaining atoms after filtering will be used to create a single group. If a string or a list of strings is given, it must include any of the following pdb property keywords [‘index’,’residue’,’sequence’,’segment’, ‘chainIdentifier’,’element’,’name’, ‘moleculeIndex’, ‘moleculeName’] that will be used to group remaining atoms after filtering into separate groups of similar groupBy properties. ‘index’ groupBy keyword take over all other keywords as it forces groups to be of single atom corresponding to the atom index. groupBy=[‘residue’,’sequence’,’segment’] is the groupBy list used by default in fullrmc to identify molecules in a pdb structure. Just like filters, groupBy keywords are not case sensitive.

  3. name (None, string): built groups name. If None is given, name will be built automatically per group

  4. subsettingSize (None, int,float,tuple): If None, no subsetting will be created. If given, all groups if given as indexes will set as subset groups otherwise groups given as groups instances won’t be touched

  5. subsettingType (string): it can be ‘random’ for RandomSubsetGroup or ‘centered’ for CenteredSubsetGroup

  6. add (boolean): whether to add newly generated groups to old ones

# import engine
from fullrmc.Engine import Engine

# create engine
ENGINE = Engine(path='my_engine.stc')

# set pdb file
ENGINE.set_pdb(pdbFileName)

# Add constraints ...

# build a single group of ti atoms confined (y,z) slice where x is between -1 and 1 angstrom
# notice that setting to False will result in removing existing groups from stochastic engine
# and set the newly created group
ENGINE.build_groups( groupBy=None, filter="element == 'ti' and -1<=x<=1", add=False )
set_molecular_groups(definitions, name='molecular', subsettingSize=None, subsettingType='random', add=False, _check=True)

Build groups of molecules and molecules’ subset given a list of definitions

Parameters:
  1. definitions (list, tuple, string, integer): list of molecular definitions. List items can be list, tuple, string or an integer.

    1. If string, this must be the molecule name and groups of molecules will be created.

    2. If integer, it will be the molecule index to create a group of

    3. If list or tuple, at least two items are required. The first item can be a molecule name, index or a list of molecule indexes. The remaining items can be any combination of string referencing atom name or element, integer referencing atom index in the molecule or a tuple of two items where the first item can be ‘name’ or ‘element’ and the second item is the atom name or element

  2. name (None, string): built groups name. If None is given, name will be built automatically per group

  3. subsettingSize (None, int,float,tuple): If None, no subsetting will be created. If given, all groups if given as indexes will set as subset groups otherwise groups given as groups instances won’t be touched

  4. subsettingType (string): it can be ‘random’ for RandomSubsetGroup or ‘centered’ for CenteredSubsetGroup

  5. add (boolean): whether to add newly generated groups to old ones

# import engine
from fullrmc.Engine import Engine

# create engine
ENGINE = Engine(path='my_engine.stc')

# set pdb file
ENGINE.set_pdb(pdbFileName)

# Add constraints ...

# set molecular groups
ENGINE.set_molecular_groups( definitions=[('THF', 'C1', 'H11', 'H12'), # grouping atoms by name or element 'C1','H11','H12' of all 'THF' molecules individually
                                          ('THF', 'O'), # grouping atoms by name or element 'O' of all 'THF' molecules individually
                                          10,0,1, # grouping all atoms of molecules index 10,0,1 individually
                                          'THF', # grouping all atoms of all 'THF' molecules individually
                                          ([0,1,100], 1,'C',10), # group atom index 1 and 10 and atoms name or element 'C' of molecules index 0,1 100 individually
                                          ([0,1,100], 1,('name','C1'),('element','O'),10),# group atom index 1 and 10 and atoms name 'C1' and atoms element 'O' of molecules index 0,1 100 individually
                                          ] )
set_groups_as_planes(plane, width=1, origin=(0, 0, 0), splits=None, combine=None, completeMolecules=False, original=True, foldIntoBox=True, filter=None, name='plane', subsettingSize=None, subsettingType='random', add=False, _evaluator=None, _raiseNoGroupsCreated=False)

Construct groups as found in parallel planes given a plane vectors, width and an origin to start creating the planes

Parameters:
  1. plane (string, list): the plane vectors representation

  2. width (number): the width of the planes

  3. origin (list): the origin that will be used as reference to start slicing the space into planes

  4. splits (None, list): list of splitting expression that can be used to split every generated plane into multiple subsets of the group prior to combining and creating the groups

  5. combine (None, integer, list, tuple): Whether to combine created planes to form groups of multiple planes. If Integer, it must be the number of planes to combine together. If list, it must be a list of lists where each list will have the indexes of planes to combine to form groups. If tuple, it must contain 2 items, the first item must be the first group index and the second one the number of planes to start combining starting from the given first group index.

  6. completeMolecules (boolean): whether to complete molecule’s atoms when any atom of a molecule is found in a plane

  7. original (boolean): whether to consider the original structure atoms coordinate or the ones of the current engine state

  8. foldIntoBox (bool): whether to fold atoms into boundary conditions box before building planes

  9. filter (None, string): filter expression string that will be evaluated to select the atoms to consider while building the planes. Expression can ingest all python math mathematical functions and constants along with all of engine atoms ‘index’, ‘residue’,’sequence’, ‘segment’,’chainIdentifier’,’element’, ‘name’, ‘x’, ‘y’, ‘z’ attributes. If None is given, all atoms are considered.

  10. name (None, string): built groups name. If None is given, name will be built automatically per group

  11. subsettingSize (None, int,float,tuple): If None, no subsetting will be created. If given, all groups will be converted to subset groups before setting to engine

  12. subsettingType (string): it can be ‘random’ for RandomSubsetGroup or ‘centered’ for CenteredSubsetGroup

  13. add (boolean): whether to add newly generated groups to old ones

# import engine
from fullrmc.Engine import Engine

# create engine
ENGINE = Engine(path='my_engine.stc')

# set pdb file
ENGINE.set_pdb(pdbFileName)

# Add constraints ...

# use a string plane
ENGINE.set_groups_as_planes(plane='xy', filter="element =='Ba'", add=False )

# split planes into 2
ENGINE.set_groups_as_planes(plane='xy', filter="element =='Ba'", splits=["name == 'Ba1'", "name != 'Ba2'"] )

# add another set of plane groups
ENGINE.set_groups_as_planes(plane=[[1,0,0],[1,-1,3]], add=True )

# add another set of plane groups combined in pairs
ENGINE.set_groups_as_planes(plane=[[1,0,0],[1,-1,3]], combine=2, add=True )
set_groups_as_rods(vector, width=1, origin=(0, 0, 0), original=True, splits=None, combine=None, completeMolecules=False, foldIntoBox=True, filter=None, subsettingSize=None, subsettingType='random', name='rod', add=False, _evaluator=None, _raiseNoGroupsCreated=False)

Construct groups as found in parallel rods (square cylinders) given a vector director and an origin to start creating the rods

Parameters:
  1. vector (string, list): the vector representation

  2. width (number): the width of the planes

  3. origin (list): the origin that will be used as reference to start slicing the space into planes

  4. original (boolean): whether to consider the original structure atoms coordinate or the ones of the current engine state

  5. splits (None, list): list of splitting expression that can be used to split every generated rod into multiple subsets of the group prior to combining and creating the groups

  6. combine (None, integer, list, tuple): Whether to combine created rods to form groups of multiple rods. If Integer, it must be the number of rods to combine together. If list, it must be a list of lists where each list will have the indexes of rods to combine to form groups. If tuple, it must contain 2 items, the first item must be the first group index and the second one the number of rods to start combining starting from the given first group index.

  7. completeMolecules (boolean): whether to complete molecule’s atoms when any atom of a molecule is found in a rod

  8. foldIntoBox (bool): whether to fold atoms into boundary conditions box before building rods

  9. filter (None, string): filter expression string that will be evaluated to select the atoms to consider while building the planes. Expression can ingest all python math mathematical functions and constants along with all of engine atoms ‘index’, ‘residue’,’sequence’, ‘segment’,’chainIdentifier’,’element’, ‘name’, ‘x’, ‘y’, ‘z’ attributes. If None is given, all atoms are considered.

  10. subsettingSize (None, int,float,tuple): If None, no subsetting will be created. If given, all groups will be converted to subset groups before setting to engine

  11. subsettingType (string): it can be ‘random’ for RandomSubsetGroup or ‘centered’ for CenteredSubsetGroup

  12. name (None, string): built groups name. If None is given, name will be built automatically per group

  13. add (boolean): whether to add newly generated groups to old ones

# import engine
from fullrmc.Engine import Engine

# create engine
ENGINE = Engine(path='my_engine.stc')

# set pdb file
ENGINE.set_pdb(pdbFileName)

# Add constraints ...

# use a string plane
ENGINE.set_groups_as_rods(vector='xy', filter="element =='Ba'", add=False )

# split rods into 2
ENGINE.set_groups_as_rods(vector='xy', filter="element =='Ba'", splits=["name == 'Ba1'", "name != 'Ba2'"] )

# add another set of plane groups
ENGINE.set_groups_as_rods(vector=[[1,0,0],[1,-1,3]], add=True )
set_supercell_groups_as_rods(vector, filter=None, splits=None, combine=None, subsettingSize=None, subsettingType='random', name='rod', add=False, _evaluator=None, _raiseNoGroupsCreated=False)

Construct groups as found in parallel supercell rods of atom indexes

Parameters:
  1. vector (string, list): the vector representation

  2. filter (None, string): filter expression string that will be evaluated to select the atoms to consider while building the planes. Expression can ingest all python math mathematical functions and constants along with all of engine atoms ‘index’, ‘residue’,’sequence’, ‘segment’,’chainIdentifier’,’element’, ‘name’, ‘x’, ‘y’, ‘z’ attributes. If None is given, all atoms are considered.

  3. splits (None, list): list of splitting expression that can be used to split every generated rod into multiple subsets of the group prior to combining and creating the groups

  4. combine (None, integer, list, tuple): Whether to combine created rods to form groups of multiple rods. If Integer, it must be the number of rods to combine together. If list, it must be a list of lists where each list will have the indexes of rods to combine to form groups. If tuple, it must contain 2 items, the first item must be the first group index and the second one the number of rods to start combining starting from the given first group index.

  5. subsettingSize (None, int,float,tuple): If None, no subsetting will be created. If given, all groups will be converted to subset groups before setting to engine

  6. subsettingType (string): it can be ‘random’ for RandomSubsetGroup or ‘centered’ for CenteredSubsetGroup

  7. name (None, string): built groups name. If None is given, name will be built automatically per group

  8. add (boolean): whether to add newly generated groups to old ones

# import engine
from fullrmc.Engine import Engine

# create engine
ENGINE = Engine(path='my_engine.stc')

# set pdb file
ENGINE.set_pdb(pdbFileName)

# Add constraints ...

# use a string plane
ENGINE.set_supercell_groups_as_rods(vector='xy', filter="element =='Ba'", add=False )

# split rods into 2
ENGINE.set_supercell_groups_as_rods(vector='xy', filter="element =='Ba'", splits=["name == 'Ba1'", "name != 'Ba2'"] )

# add another set of plane groups
ENGINE.set_supercell_groups_as_rods(vector=[[1,0,0],[1,-1,3]], add=True )
set_supercell_groups_as_planes(plane, filter=None, splits=None, combine=None, subsettingSize=None, subsettingType='random', name='plane', add=False, _evaluator=None, _raiseNoGroupsCreated=False)

Construct groups as found in parallel supercell planes of atom indexes

Parameters:
  1. plane (string, list): the plane vectors representation

  2. filter (None, string): filter expression string that will be evaluated to select the atoms to consider while building the planes. Expression can ingest all python math mathematical functions and constants along with all of engine atoms ‘index’, ‘residue’,’sequence’, ‘segment’,’chainIdentifier’,’element’, ‘name’, ‘x’, ‘y’, ‘z’ attributes. If None is given, all atoms are considered.

  3. splits (None, list): list of splitting expression that can be used to split every generated plane into multiple subsets of the group prior to combining and creating the groups

  4. combine (None, integer, list, tuple): Whether to combine created planes to form groups of multiple planes. If Integer, it must be the number of planes to combine together. If list, it must be a list of lists where each list will have the indexes of planes to combine to form groups. If tuple, it must contain 2 items, the first item must be the first group index and the second one the number of planes to start combining starting from the given first group index.

  5. subsettingSize (None, int,float,tuple): If None, no subsetting will be created. If given, all groups will be converted to subset groups before setting to engine

  6. subsettingType (string): it can be ‘random’ for RandomSubsetGroup or ‘centered’ for CenteredSubsetGroup

  7. name (None, string): built groups name. If None is given, name will be built automatically per group

  8. add (boolean): whether to add newly generated groups to old ones

# import engine
from fullrmc.Engine import Engine

# create engine
ENGINE = Engine(path='my_engine.stc')

# set pdb file
ENGINE.set_pdb(pdbFileName)

# Add constraints ...

# use a string plane
ENGINE.set_supercell_groups_as_planes(plane='xy', filter="element =='Ba'", add=False )

# split planes into 2
ENGINE.set_supercell_groups_as_planes(plane='xy', filter="element =='Ba'", splits=["name == 'Ba1'", "name != 'Ba2'"] )

# add another set of plane groups
ENGINE.set_supercell_groups_as_planes(plane=[[1,0,0],[1,-1,3]], add=True )
set_groups_as_atoms(name='atom', add=False)

Helper method to create groups as single atom group for all atoms. If add is True, created groups will be added to engine existing ones otherwise old groups will be removed.

Parameters:
  1. name (string, list): groups name. If string is given, the same name will be given to all groups. If list is given, it must have the same length as the number of molecules in the system

  2. add (boolean): whether to add newly generated groups to old ones

set_groups_as_molecules(name='molecule', subsettingSize=None, subsettingType='random', add=False)

Helper method to automatically to create molecular groups of atom indexes according to molecules indexes. If add is True, created groups will be added to engine existing ones otherwise old groups will be removed.

When parsing the pdb structure file, fullrmc considers a molecule as the consecutive collection of atoms sharing the same ‘Residue name’, ‘Sequence number’ and ‘Segment identifier’.

Parameters:
  1. name (string, list): groups name. If string is given, the same name will be given to all groups. If list is given, it must have the same length as the number of molecules in the system

  2. subsettingSize (None, int,float,tuple): If None, no subsetting will be created. If given, all groups will be converted to subset groups before setting to engine

  3. subsettingType (string): it can be ‘random’ for RandomSubsetGroup or ‘centered’ for CenteredSubsetGroup

  4. add (boolean): whether to add newly generated groups to old ones

set_groups_as_unitcells(name='unitcell', *args, **kwargs)

Create groups as unitcells. If supercell is not defined, an error will be raised. Otherwise, this is simply an alias to set_groups_as_molecules

create_supercell_set_pdb(maker, supercell=None, _log=True)

Using pdbparser.Utilities.Crystallography.CrystalMaker, create a supercell and set pdb structure

Parameters:
  1. maker (pdbparser.Utilities.Crystallography.CrystalMaker): maker instance

  2. supercell (None, tuple): supercell dimension to create. If None then a supercell of the size of the unit cell will be created.

build_crystal_set_pdb(symOps, atoms, unitcellBC, supercell=None, _allowOccupancy=False, _log=True)

Build crystal using symmetry operations, atoms coordinates and occupancy and unitcell boundary conditions

Parameters:
  1. symOps (list): list of symmetry operations

  2. atoms (atoms): list of tuples where every tuple contains the atom element name, x,y,z coordinates and an optional occupancy. If an atom occupancy is missing, it’s then considered to be 1

  3. unitcellBC (list, numpy.ndarray, pdbparser.Utilities.BoundaryConditions.PeriodicBoundaries): unitcell boundary conditions instance or parameters defining the unitcell size and shape. When a list of parameters is given, it can be a list of the 6 crystallographic lattice parameters (a,b,c,alpha,beta,gamma) or a list of the three boundary condition vectors for (X,Y,Z). If numpy.ndarray is given, it must be an array matrix of shape (3,3) defining the three boundary condition vectors (X,Y,Z) of the boundary conditions.

  4. supercell (None, tuple): supercell dimension to create. If None then a supercell of the size of the unit cell will be created.

Returns:
  1. maker (pdbparser.Utilities.Crystallography.CrystalMaker): the crystal maker instance

# import engine
from fullrmc.Engine import Engine

# create engine
ENGINE = Engine(path='my_engine.stc')

# build a supercell crystal structure and set it as the engine's structure
symOps = ['X,Y,Z', '-X,Y,-Z', '-X,-Y,-Z', 'X,-Y,Z',
          '1/2+X,1/2+Y,Z', '1/2-X,1/2+Y,-Z', '1/2-X,1/2-Y,-Z',
          '1/2+X,1/2-Y,Z']
atoms     = [('Co',0,0,0,1),('O',0,0.5,1),]
a         = 5.18
b         = 3.015
c         = 3.017
alpha     = 90.    # (alpha, the angle between b and c)
beta      = 125.55 # (beta,  the angle between a and c)
gamma     = 90.    # (gamma, the angle between a and b)
ENGINE.build_crystal_set_pdb(symOps     = symOps,
                             atoms      = atoms,
                             unitcellBC = [a,b,c,alpha,beta,gamma],
                             supercell  = (20,20,20))

# Add constraints ...
# Re-define groups if needed ...
# Re-define groups selector if needed ...
# Re-define moves generators if needed ...

# save engine
ENGINE.save()

# run engine for 10000 steps and save only at the end
ENGINE.run(numberOfSteps=10000, saveFrequency=10000)
read_cif_set_pdb(cif, supercell=None, _readPdbAtomsAttribute=True, _allowOccupancy=False, _log=True)

Set pdb structure using a .cif file. Cif files come in different flavors and they are hardly standardized.

Parameters:
  1. cif (string, pathlike): cif file path. fullrmc looks for the following information in a cif:

  2. cell information as a space separated 2 columns lines (e.g. _cell_length_a 13.5049(4)) ‘_cell_length_a’, ‘_cell_length_b’, ‘_cell_length_c’, ‘_cell_angle_alpha’, ‘_cell_angle_beta’, ‘_cell_angle_gamma’

  3. loop block containing atoms site factional position with all of ‘_atom_site_fract_x’, ‘_atom_site_fract_y’, ‘_atom_site_fract_z’ and either ‘_atom_site_type_symbol’ or ‘_atom_site_label’

  4. loop block containing symmetry operations with either ‘_space_group_symop_operation_xyz’ or ‘_symmetry_equiv_pos_as_xyz’ If neither are defined, ‘_space_group_name_H-M_alt’ attribute is looked for to map Hermann-Mauguin symbol to Hall symbol and then generating symmetry operations from HALL_TO_SYM_OPS

  5. supercell (None, tuple): supercell dimension to create. If None then a supercell of the size of the unit cell will be created.

_cell_length_a        12.046(3)
_cell_length_b        8.147(1)
_cell_length_c        7.548(2)
_cell_angle_alpha     90
_cell_angle_beta      121.83(2)
_cell_angle_gamma     90
loop_
_symmetry_equiv_pos_as_xyz
x,y,z
-x,y,1/2-z
-x,-y,-z
x,-y,1/2+z
1/2+x,1/2+y,z
1/2-x,1/2+y,1/2-z
1/2-x,1/2-y,-z
1/2+x,1/2-y,1/2+z
loop_
_atom_site_label
_atom_site_type_symbol
_atom_site_symmetry_multiplicity
_atom_site_Wyckoff_symbol
_atom_site_fract_x
_atom_site_fract_y
_atom_site_fract_z
_atom_site_occupancy
_atom_site_attached_hydrogens
_atom_site_calc_flag
V1 V4+ 4 e 0. 0.7556(3) 0.25 1. 0 d
P1 P1+ 8 f 0.2271(2) 0.6658(3) 0.7122(4) 1. 0 d
O1 O2- 8 f 0.1437(3) 0.7861(4) 0.5472(5) 1. 0 d
O2 O2- 8 f 0.1274(3) 0.7922(4) 0.1589(5) 1. 0 d
O3 O2- 4 e 0. 0.0337(5) 0.25 1. 2 d
O4 O2- 4 e 0. 0.5653(7) 0.25 1. 0 d
Parameters:
  1. cif (string, list): the cif file path or a list of cif file string lines.

  2. supercell (None, tuple): supercell dimension to create. If None then a supercell of the size of the unit cell will be created.

Returns:
  1. maker (pdbparser.Utilities.Crystallography.CrystalMaker): the crystal maker instance

read_xyz_set_pdb(xyz, boundaryConditions=None, names=None, elements=None, moleculesIndex=None, moleculesName=None)

Set pdb structure using a XYZ chemical file format. Unlike a pdb file, xyz has no molecular information and therefore molecules will not be automatically parsed using a xyz file. All atoms are considered non-bonded.

There is no formal standard format for xyz file. fullrmc adopts the typical format where the atomic system geometry is specified by giving the number of atoms on the first line and a single comment on the second line. Atomic coordinates data start from the third line. Atomic lines are empty space separated and each atomic line must include exactly 4 columns for respectively the atomic element, x, y and z coordinates in the cartesian coordinates system.

In addition, fullrmc allows adding comment lines using ‘#’ at the beginning of a comment line.

Boundary conditions comments are allowed and those must be used as in the following example (# Boundary Conditions: 45.75 0.0 0.0 0.0 45.75 0.0 0.0 0.0 45.75)

# Boundary Conditions: 45.75  0.0  0.0  0.0  45.75  0.0  0.0  0.0  45.75
6750
shape memory NiTi alloy
Ni 35.884  30.895  49.120
Ti 36.177  29.853  50.124
Ni 37.296  30.296  51.074
Ti 38.553  30.400  50.259
Ni 38.357  31.290  49.044
Ti 39.559  31.209  48.082
Ni 34.968  30.340  48.234
Ti 34.923  29.775  50.910
Ni 37.441  29.265  52.113
Ti 39.572  30.954  51.086
Ni 37.155  30.858  48.364
Ti 39.261  32.018  46.920
.
.
.
Parameters:
  1. xyz (string, list): the xyz file path or a list of xyz file string lines.

  2. boundaryConditions (None, InfiniteBoundaries, PeriodicBoundaries, numpy.ndarray, number): The configuration’s boundary conditions. If None, boundaryConditions will be parsed from pdb if existing otherwise, InfiniteBoundaries with no periodic boundaries will be set. If numpy.ndarray is given, it must be pass-able to a PeriodicBoundaries instance. Normally any real numpy.ndarray of shape (1,), (3,1), (9,1), (3,3) is allowed. If number is given, it’s like a numpy.ndarray of shape (1,), it is assumed as a cubic box of box length equal to number.

  3. names (None, list): Atoms names list. If None is given, names will be the same the atom element.

  4. elements (None, list): Atoms elements list. If None is given, elements will be calculated set by parsing the xyz file

  5. moleculesIndex (None, list, numpy.ndarray): Molecules index list. Must have the length of number of atoms. If None is given, moleculesIndex will be set automatically to the number of atoms in the system

  6. moleculesName (None, list): Molecules name list. Must have the length of the number of atoms. If None is given, it is automatically set to ‘XYZ’

set_structure_supercell(size)

Compute and set structure’s supercell attributes. This assumes that the current pdb structure is crystal (like) where atoms in unitcells are created as separate molecules in the pdb. The same sequence of unique atom names are expected in all unitcells. Occupancy and voids are accounted for as long as the sequence of atom names is respected.

Parameters:
  1. size (None, list,tuple,numpy.ndarray): The structure supercell dimension as (i,j,k) where i is the number of unitcells along x axis, j is the number of unitcells along y axis and k the number of unitcells along z axis. If None is given, supercell structure properties will be removed.

set_pdb(pdb, boundaryConditions=None, names=None, elements=None, moleculesIndex=None, moleculesName=None, _supercell=None, _checkForInconsistencies=True, _reinitting=False, _log=True)

Set used frame pdb configuration. Engine and constraints data will be automatically reset but not constraints definitions. If pdb was already set and this is a resetting to a different atomic configuration, with different elements or atomic order, or different size and number of atoms, constraints definitions must be reset manually. In general, their is no point in changing the atomic configuration of a completely different atomic nature. It is advisable to create a new engine from scratch or redefining all constraints definitions.

REMARK    this file is generated using 'pdbparser' package
REMARK    Boundary Conditions: 30.0  0.0  0.0  0.0  30.0  0.0  0.0  0.0  30.0
ATOM      1 Co01 UNK     1      14.620  16.640  14.930  1.00  0.00          Co
ATOM      2 Co02 UNK     1      14.060  14.080  16.150  1.00  0.00          Co
ATOM      3 Co03 UNK     1      16.580  14.800  15.380  1.00  0.00          Co
ATOM      4 Co04 UNK     1      14.540  14.340  13.500  1.00  0.00          Co
ATOM      5 O001 UNK     1      13.440  15.180  14.760  1.00  0.00           O
.
.
.
Parameters:
  1. pdb (pdbparser, string, list): the configuration pdb as a pdbparser instance or a path string to a pdb file or a list of pdb lines.

  2. boundaryConditions (None, InfiniteBoundaries, PeriodicBoundaries, numpy.ndarray, number): The configuration’s boundary conditions. If None, boundaryConditions will be parsed from pdb if existing otherwise, InfiniteBoundaries with no periodic boundaries will be set. If numpy.ndarray is given, it must be pass-able to a PeriodicBoundaries instance. Normally any real numpy.ndarray of shape (1,), (3,1), (9,1), (3,3) is allowed. If number is given, it’s like a numpy.ndarray of shape (1,), it is assumed as a cubic box of box length equal to number.

  3. names (None, list): Atoms names list. If None is given, names will be automatically extracted by parsing pdb instance.

  4. elements (None, list): Atoms elements list. If None is given, elements will be automatically extracted by parsing pdb instance.

  5. moleculesIndex (None, list, numpy.ndarray): Molecules index list. Must have the length of number of atoms. If None is given, moleculesIndex will be set automatically set by parsing pdb instance.

  6. moleculesName (None, list): Molecules name list. Must have the length of the number of atoms. If None is given, it is automatically generated using the pdb residues name. Molecules name are very important to be unique per type of molecule because this is the only differentiating factor when setting definitions by molecule.

  7. _supercell: For internal use only

set_boundary_conditions(boundaryConditions, frame=None, autoAdjust=False, _nAtoms=None, _broadcast=True)

Sets the configuration’s boundary conditions. Any type of periodic or infinite boundary conditions is allowed and not restricted to cubic. Engine and constraints data will be automatically reset. Number density will be automatically calculated upon setting boundary conditions. In the case where inifinite boundaries are set, which is needed to simulate isolated atomic systems such as nano-particles, the volume is theoretically infinite and therefore number density must be 0. But experimentally the measured samples are diluted in solvants and the actual number density must be the experimental one. To avoid numerical instabilities, number density will be automatically set to water’s one equal to 0.0333679 and volume will be adjusted to the ratio of number of atoms devided to the given water number density. If this number is not accurate, user can always set the appropriate number density using the stochastic engine ‘set_number_density’ method

Parameters:
  1. boundaryConditions (None, InfiniteBoundaries, PeriodicBoundaries, numpy.ndarray, number): The configuration’s boundary conditions. If None, InfiniteBoundaries with no periodic boundaries will be set. If numpy.ndarray is given, it must be pass-able to a PeriodicBoundaries instance. Normally any real numpy.ndarray of shape (1,), (3,1), (9,1), (3,3) is allowed. If number is given, it’s like a numpy.ndarray of shape (1,), it is assumed as a cubic box of box length equal to number.

  2. frame (None, string): Target frame name. If None, engine used frame is used. If multiframe is given, all subframes boundary conditions will be changed

  3. autoAdjust (bool): automatically adjust certain engine and constraints properties that should be changed along with boundaryConditions (e.g. PairDistributionConstraint.set_shape_function_parameters)

  4. _nAtoms: for internal use only

  5. _broadcast (boolean): for internal use only

set_number_density(numberDensity, frame=None, _nAtoms=None, _broadcast=True)

Sets system’s number density. This is used to correct system’s volume. It can only be used with InfiniteBoundaries.

Parameters:
  1. numberDensity (number): Number density value that should be bigger than zero.

  2. frame (None, string): Target frame name. If None, engine used frame is used. If multiframe is given, all subframes boundary conditions will be changed

  3. _nAtoms: for internal use only

set_real_coordinates(coordinates, frame=None, _broadcast=True)

Set frame real coordinates. Meant for internal use only.

Parameters:
  1. coordinates (numpy.ndarray):coordinates array

  2. frame (None, string): frame name or None to update usedFrame

  3. _broadcast (boolean): for internal use only

check_molecules_inconsistencies()

Check whether engine molecules are inconsistent or not

Returns:
  1. result (bool): True if any inconsistencies are found, False otherwise

autofix_molecules_atomic_inconsistencies()

Automatically fix molecules atomic inconsistencies in the frame

rename_molecules(molecules, force=False)

Rename molecules given look up table

Parameters:
  1. molecules (dict): dictionary of old to new molecules name

  2. force (bool): whether to force changing molecule name to molecules name that already exist in the system

# import engine
from fullrmc.Engine import Engine

# create engine
ENGINE = Engine(path='my_engine.stc')

# set pdb file
ENGINE.set_pdb(pdbFileName)

# re-defined molecules for a an atomic system
molecules = {'MOL':'THF', 'RMC':'CH4'}
ENGINE.rename_molecules(molecules)
rename_molecule_atoms(molecules)

Rename atoms in a molecule.

Parameters:
  1. molecules (dict): dictionary of molecules name where values are dictionaries or a list of (name/index, new name) pairs

# import engine
from fullrmc.Engine import Engine

# create engine
ENGINE = Engine(path='my_engine.stc')

# set pdb file
ENGINE.set_pdb(pdbFileName)

# re-defined molecules for a an atomic system
molecules = {'MOL':{'O':'O1', 1:'Ti'}, 'THF':[('H11','H_1'),(2,'O')]}
ENGINE.rename_molecule_atoms(molecules)
define_molecules(molecules)

Define molecules using a lookup table of molecules name and list of atoms index. Each atom in the system must be defined in one single molecule. This method can be called when used frame is a subframe or when only a single traditional frame is defined which is the default frame ‘0’.

Parameters:
  1. molecules (dict): dictionary of molecules name. Values are a list of atom indexes or a list of lists of atom indexes. If a molecule value is a list then all atoms of that list will belong to the same molecule. When value is a list of lists, then atoms will be split into multiple molecules. Molecules sharing the same name will be tested for consistency in terms of atom names and elements order.

# import engine
from fullrmc.Engine import Engine

# create engine
ENGINE = Engine(path='my_engine.stc')

# set pdb file
ENGINE.set_pdb(pdbFileName)

# re-defined molecules for a an atomic system
molecules = {}
for idx,el in enumerate(ENGINE.allElements):
    molecules.setdefault('MOL_%s'%el,[]).append(idx)
ENGINE.define_molecules(molecules)
set_molecules_index(moleculesIndex=None, moleculesName=None, _checkForInconsistencies=True, _reinitting=False, _broadcast=True)

Set moleculesIndex list, assigning each atom to a molecule.

Parameters:
  1. moleculesIndex (None, list, numpy.ndarray): Molecules index list. Must have the length of the number of atoms. If None is given, moleculesIndex will be calculated automatically by parsing pdb and grouping atoms by unique sets of (residue,sequence,segment).

  2. moleculesName (None, list): Molecules name list. Must have the length of the number of atoms. If None is given, it will be automatically generated as the pdb residues name.

  3. _checkForInconsistencies (boolean): for internal use only

  4. _reinitting (boolean): for internal use only

  5. _broadcast (boolean): for internal use only

set_elements_index(elements=None, _broadcast=True)

Set elements and elementsIndex lists, assigning a type element to each atom.

Parameters:
  1. elements (None, list): Elements list, it must have the length of the number of atoms. If None is given, elements will be calculated automatically by parsing pdb instance.

  2. _broadcast (boolean): for internal use only

set_names_index(names=None, _broadcast=True)

Set names and namesIndex list, assigning a name to each atom.

Parameters:
  1. names (None, list): The names list. If None is given, names will be generated automatically by parsing pdbparser instance.

  2. _broadcast (boolean): for internal use only

visualize(frame=None, commands=None, foldIntoBox=False, contiguous=False, boxToCenter=False, boxWidth=2, boxStyle='solid', boxColor='yellow', bgColor='black', displayParams=None, representationParams='Lines', otherParams=None, _mergeResolution=None)

Visualize the last configuration using pdbparser visualize_vmd method.

Parameters:
  1. frame (None, string): The frame to visualize. If None, used frame will be visualized. If given, frame must be created in repostory.

  2. commands (None, list, tuple): List of commands to pass upon calling vmd.

  3. foldIntoBox (boolean): Whether to fold all atoms into PeriodicBoundaries box before visualization. If boundary conditions are InfiniteBoundaries then nothing will be done.

  4. contiguous (boolean): Whether to build contiguous molecules using PeriodicBoundaries box. If boundary conditions are InfiniteBoundaries then nothing will be done.

  5. boxToCenter (boolean): Translate box center to atom coordinates center.

  6. boxWidth (number): Visualize the simulation box by giving the lines width. If 0 or boundary conditions are InfiniteBoundaries then nothing is visualized.

  7. boxStyle (str): The box line style, it can be either solid or dashed. If boundary conditions are InfiniteBoundaries then nothing will be done.

  8. boxColor (str): Choose the simulation box color. If boundary conditions are InfiniteBoundaries then nothing will be done. Available colors are:

    blue, red, gray, orange, yellow, tan, silver, green, white, pink, cyan, purple, lime, mauve, ochre, iceblue, black, yellow2, yellow3, green2, green3, cyan2, cyan3, blue2, blue3, violet, violet2, magenta, magenta2, red2, red3, orange2, orange3.

  9. bgColor (str): Set visualization background color.

  10. displayParams(None, dict): Set display parameters. If None is given, default parameters will be applied. If dictionary is given, the following keys can be used.

    • ‘depth cueing’ (default True): Set the depth cueing flag.

    • ‘cue density’ (default 0.1): Set the depth density.

    • ‘cue mode’ (default ‘Exp’): Set the depth mode among ‘linear’, ‘Exp’ and ‘Exp2’.

  11. representationParams(str): Set representation method among the following:

    Lines, Bonds, DynamicBonds, HBonds, Points, VDW, CPK, Licorice, Beads, Dotted, Solvent.

    Add parameters accordingly if needed like the following.

    • Points representation accept only size parameter e.g. ‘Points 5’

    • CPK representation can accept respectively 4 parameters as the following ‘Sphere Scale’, ‘Bond Radius’, ‘Sphere Resolution’, ‘Bond Resolution’ e.g. ‘CPK 1.0 0.2 50 50’

    • VDW representation can accept respectively 2 parameters as the following ‘Sphere Scale’, ‘Sphere Resolution’ e.g. ‘VDW 0.7 100’

  12. otherParams(None, list, set, tuple): Any other parameters in a form of a list of strings.

    e.g. [‘display resize 700 700’, ‘rotate x to 45’, ‘scale to 0.02’, ‘axes location off’]

add_constraints(*args, **kwargs)

Add constraints to the engine. If used frame is a normal frame, all other normal frames will have the constraints added. If used frame is a subframe, all other subframes of the same multiframe will have the experimental constraints added to. But given non-experimental constraints will be only added to the used frame.

Parameters:
  1. constraints (Constraint, list, set, tuple): A constraint instance or list of constraints instances

  2. allSubframes (boolean): Whether to also add non-experimental constraints to all other multiframe subframes in case engine used frame is a multiframe subframe.

remove_constraints(*args, **kwargs)

Remove constraints from engine list of constraints.

Parameters:
  1. constraints (Constraint, list, set, tuple): A constraint instance or list of constraints instances.

  2. allSubframes (boolean): Whether to also remove non-experimental constraints from all other multiframe subframes in case engine used frame is a multiframe subframe.

reset_constraints(used=False, _log=True)

Reset used frame constraints flags.

Parameters:
  1. used (boolean): whether to reset used constraints only

reset_engine(_log=True)

Re-initialize engine and resets constraints flags and data.

normalize_constraints_variance(used=True)

Engine total standard error is computed as the sum of all used experimental constraints’ standard error divided by the variance.

This method will automatically update each constraint variance to normalize constraints contribution to the engine’s total standard error as the follows.

\[variance = \frac{\sum \limits_{i}^{N} \left|y_{i}\right|}{min \left[ \sum \limits_{j}^{M} \left|y_{j}\right| \right]}\]

Where:

\(N\) is the number of experimental constraint data point within the used limits.

\(M\) is the number of used experimental constraints.

\(y_{i}\) is the constraint i^{th} experimental data within the used limits.

\(min \left[ \sum \limits_{j}^{M} \left|y_{j}\right| \right]\) is the minimum of all experimental constraints absolute sum of values.

Parameters:
  1. used (boolean): whether to only update used experimental constraints variance

reset_constraints_variance(used=True, _log=True)

Engine total standard error is computed as the sum of all used experimental constraints’ standard error divided by the variance.

This method will automatically reset each constraint variance to the following

\[variance = \sum \limits_{i}^{N} \frac{\left( y_{i}-\bar{y} \right)^{2}}{N}\]

Where:

\(N\) is the number of experimental constraint data point within the used limits.

\(y_{i}\) is the constraint \(i^{th}\) experimental data within the used limits.

\(\bar{y}\) is the average of the constraint’s experimental data value within the used limits.

Parameters:
  1. used (boolean): whether to only update used experimental constraints variance

equate_constraints_variance(used=True)

Engine total standard error is computed as the sum of all used experimental constraints’ standard error divided by the variance.

This method will automatically reset each constraint variance to 1

Parameters:
  1. used (boolean): whether to only update used experimental constraints variance

compute_total_standard_error(constraints, current='standardError')

Compute the total standard error as the sum of all used experimental constraints’ standard error.

\[totStdError = \sum \limits_{i}^{N} \frac{stdErr_{i}}{variance_{i}}\]

Where:

\(variance_{i}\) is the variance value of the constraint i.

\(totStdError\) the engine total standard error \(stdErr_{i}\) the standard error of the constraint i defined as \(\sum \limits_{j}^{points} (target_{i,j}-computed_{i,j})^{2} = (Y_{i,j}-F(X_{i,j}))^{2}\)

Parameters:
  1. constraints (list): All constraints used to calculate total totalStandardError.

  2. current (str): which standard error to use. Can be anything like standardError, afterMoveStandardError or amputatedStandardError, etc.

Returns:
  1. totalStandardError (float): The computed total standard error.

update_total_standard_error()

Compute and set engine’s total totalStandardError of used constraints.

get_constraints(used=True, sortConstraints=False)

Fetches all engine’s constraints and returns different lists of constraints.

Parameters:
  1. used (boolean): whether to initialize used constraints only. If True, returned lists will contain only used constraints

  2. sortConstraints (boolean): Whether to sort used constraints according to their computation cost property. This can minimize computations and enhance performance by computing less costly constraints first.

Returns:
  1. usedConstraints (list): All types of active constraints instances that are used at engine’s runtime.

  2. stdConstraints (list): All active constraints instance among usedConstraints list that will contribute to engine’s totalStandardError.

  3. rigidConstraints (list): All active RigidConstraint constraints instance among usedConstraints list that won’t contribute engine’s totalStandardError.

initialize_constraints(used=True, force=False, resetLoss=False, sortConstraints=False, _log=True)

Calls get_constraints method, re-initializes constraints when needed and return them all.

Parameters:
  1. used (boolean): whether to initialize used constraints only. If True, returned lists will contain used constraints only.

  2. force (boolean): Whether to force initializing constraints regardless of their state.

  3. resetLoss (boolean): Whether to reset loss function prior to starting the engine. This will only take effect if chosen loss is not static but machine learning enabled.

  4. sortConstraints (boolean): Whether to sort used constraints according to their computation cost property. This can minimize computations and enhance performance by computing less costly constraints first.

Returns:
  1. usedConstraints (list): All types of active constraints instances that are used at engine’s runtime.

  2. stdConstraints (list): All active constraints instance among usedConstraints list that will contribute to engine’s totalStandardError.

  3. rigidConstraints (list): All active RigidConstraint constraints instance among usedConstraints list that won’t contribute engine’s totalStandardError.

run(numberOfSteps=100000, frame=None, resetLoss=False, updateLoss=True, sortConstraints=True, optimize=True, saveFrequency=1000, xyzFrequency=None, restartPdb='restart.pdb', xyzPath='trajectory.xyz', ncores=1)

Run stochastic fitting engine.

Parameters:
  1. numberOfSteps (integer): The number of steps to run.

  2. frame (None, frame): The frame to use to run the engine. If None is given, engine usedFrame will be used

  3. resetLoss (boolean): Whether to reset loss function prior to starting the engine. This will only take effect if chosen loss is not static but machine learning enabled.

  4. updateLoss(boolean): Whether to train loss function during stochastic engine runtime. This will only take effect if chosen loss is not static but machine learning enabled.

  5. sortConstraints (boolean): Whether to sort used constraints according to their computation cost property. This can minimize computations and enhance performance by computing less costly constraints first.

  6. optimize (boolean): Whether to optimize parameters during stochastic engine runtime. Optimization parameters are defined separately in the engine constraints

  7. saveFrequency (integer): Save engine every saveFrequency steps. Save will be omitted if no moves are accepted.

  8. xyzFrequency (None, integer): Save coordinates to .xyz file every xyzFrequency steps regardless if totalStandardError has decreased or not. If None is given, no .xyz file will be generated.

  9. restartPdb (None, string): Export a pdb file of the last configuration at the end of the run. If None is given, no pdb file will be exported. If string is given, it should be the full path of the pdb file.

  10. xyzPath (string): Save coordinates to .xyz file.

  11. ncores (None, integer): set the number of cores to use. If None is given, ncores will be set automatically to maximum number of cores in the machine. This argument is only effective if fullrmc is compiled with openmp.

property optimizer_usedConfiguration

Optimized current used configuration

property optimizer_optimizedParameters

The used optimizer optimized parameters dictionary

optimizer_add_configuration(name)

Add optimization structure to engine

Parameters:
  1. name (str): structure user defined name

optimizer_remove_configuration(name)

Remove optimization structure from engine

Parameters:
  1. name (str): structure user defined name

optimizer_rename_configuration(name, newName)

Rename optimization structure from engine

Parameters:
  1. name (str): structure user defined name

  2. newName (str): structure new user defined name

optimizer_get_constraints_parameters(name=None, uniqueID=None)

Get optimized structure constraints data given user defined name or uniqueID

Parameters:
  1. name (None, string): optimization name. If None then uniqueID must be given

  2. uniqueID (None, string): if given, name will be ignored

Returns:
  1. data (dict): dictionary of all constraints data

optimizer_set_used_configuration(name, uniqueID=None)

Set used optimization given user defined name or uniqueID

Parameters:
  1. name (None, string): optimization name. If None then uniqueID must be given

  2. uniqueID (None, string): if given, name will be ignored

optimizer_set_structure(cif, scaleup, supercell, keepExpCons=True, **setkwargs)

Set used optimization structure. This will result in resetting optimization engine and removing all existing optimizations for the previous structure

Parameters:
  1. cif (string, dict): if string is given it must point to a cif file path. If a dict is given, it will be used to build an initital structure using pdbparser CrystalBuilder

  2. scaleup (None, tuple): if given this will be used to create a bigger unitcell from the main unitcell. This can be used to refine more complex structures where inter-unitcells anisotropic correlations are present. The new constructed unitcell will be used later in the supercell creation.

  3. supercell (tuple): defines how big of a supercell is needed

  4. keepExpCons (boolean): whether to keep existing experimental constraints definition. If False, previously set experimental constraint will be removed.

optimizer_set_stucture_redefinitions(**kwargs)

Set structure re-definitions. Used keyword arguments are ‘atomsName’, ‘moleculesName’, ‘moleculesIndex’ and values must be lists of the same length as unitcell number of atoms. All other kwargs will be stored but ignored

optimizer_set_supercell(*args, **kwargs)

Set optimizer supercell

optimizer_set_optimization_distance(*args, **kwargs)

Set optimizer optimization distance

optimizer_set_scaleup(*args, **kwargs)

Set optimizer supercell

optimizer_reset_structure()

Reset optimizer structure to the one as given in CIF file

optimizer_set_experimental_constraint(consClass='PairDistributionConstraint', _update=True, **params)

Add experimental constraint to optimizer

Parameters:
  1. consClass (string): type of experimental constraint to add

  2. params (dict): Any set of parameters used to instanciate fullrmc.Constraint.PairDistributionConstraints.PairDistributionConstraint or fullrmc.Constraint.PairCorrelationConstraints.PairCorrelationConstraint or fullrmc.Constraint.RadialDistributionConstraints.RadialDistributionConstraint

optimizer_update_experimental_constraint(_update=True, **params)

Add experimental constraint to optimizer

Parameters:
  1. params (dict): Any set of parameters used to update the experimental constraint

optimizer_remove_experimental_constraint(_update=True)

Remove experimental constraint from optimizer if existing

optimizer_set_distances_constraint(**params)

Add atoms distance constraint to optimizer

Parameters:
  1. params (string, numpy.ndarray): distances definition parameters

optimizer_set_bonds_constraint(*args, **kwargs)

Add atoms bond constraint to optimizer

optimizer_set_angles_constraint(*args, **kwargs)

Add atoms angle constraint to optimizer

optimizer_set_dihedrals_constraint(*args, **kwargs)

Add atoms dihedral constraint to optimizer

optimizer_set_impropers_constraint(*args, **kwargs)

Add atoms dihedral constraint to optimizer

optimizer_save(_log=True)

Save optimizer used state. Normally this is done automatically but that can be another way to force dumping state to repository ‘state_used’ file

optimizer_restore_last_state()

Load optimizer ‘state_used’. This can be invoked to restore optimizer state

optimizer_backup_state(name='backup', _addTimeStamp=True)

Save current state in order to retrieve it later

Parameters:
  1. name (str): state name to backup

optimizer_restore_state(name)

Save current state in order to retrieve it later

Parameters:
  1. name (str): optimizer saved state name to restore

optimizer_delete_state(name)

Delete optimizer backed-up state

Parameters:
  1. name (str): optimizer saved state name to be delete

optimizer_set_parameters(**params)

Set optimizer parameters

optimizer_run_optimization(*args, **kwargs)

Run optimizer

Parameters:
  1. params (string, numpy.ndarray): Any set of parameters to pass to optimizer run method

optimizer_run(*args, **kwargs)

Alias to optimizer_run_optimization

optimizer_set_optimization_result(saveStateKwargs=None, *args, **kwargs)

Set optimizer structure

Parameters:
  1. saveStateKwargs (None, dict): If given this will be used to pass to ‘optimizer_backup_state’ method

  2. params (string, numpy.ndarray): Any set of parameters to pass to optimizer set optimized structure method

optimizer_configuration_to_stochastic(multiframe, subframe, confName=None, supercell=None, contiguous=True, optimizedStructure=True, addExperimentalConstraint=True, addRigidConstraints=True, RemoveExistingExperimentalConstraints=False, _autoSubframeName=True)

Convert an optimized configuration to a stochastic statistical multiframe.

Parameters:
  1. multiframe (string): the statistical multiframe to use or to create

  2. subframe (string): the subframe name to create or to use

  3. confName (None, string): the configuration name to use. If None, the optimizer used configuration will be set

  4. supercell (None, tuple): the supercell size. If None, the optimization supercell will be used

  5. contiguous (boolean): build frame from contiguous unitcell

  6. optimizedStructure (boolean): build frame from the final optimized structure

  7. addExperimentalConstraint (boolean): whether to add optimization experimental constraints to the created stochastic frame

  8. addRigidConstraints (boolean): whether to add optimization rigid constraints to the created stochastic frame

  9. RemoveExistingExperimentalConstraints (boolean): whether to remove any existing experimental constraints already set on the frame prior to adding the optimization’s ones

class fullrmc.Engine.Grains_Engine(parent, multiframe, *args, **kwargs)

Bases: Engine

Coarse grains engine that is meant to be used along a normal Engine in multiframe calculations.

Parameters:
  1. parent (fullrmc.Engine): fullrmc parent engine

  2. multiframe (string): parent engine multiframe in use. It must be a nanoscopic multiframe

property multiframe

Parent engine multiframe in use

property subframes

Parent engine multiframe subframes

property subframsLUT

Parent engine multiframe subframes to subframe index look up table

property grainsWeight

Grains weight array which indicates the number of atoms per grains

property grainSize

Grain size in angstrom

property structure

Multiframe structure dictionary

property numberOfGrains

Number of grains.

property numberOfAtoms

Number of atoms as the total sum of all grains weight.

property numberOfAtomsPerGrain

Get average number of atoms per grains

property constraintsCloneLUT

Dictionary of all cloned constraints mapping to the original constraint name in parent engine

property subframeGrainsLUT

Dictionary of subframes index keys and values are all grains indexes that belong to the subframe

save(*args, **kwargs)

Disabled. Grains_Engine shares its parent engine’s repository and must not save independently. This is a deliberate no-op; save the parent engine instead.

set_grains(grainsElement, grainsWeight, moleculesIndex, subframesIndex, coordinates)

Set engine grains which is the replacement to set_pdb for a grain engine.

Parameters:
  1. grainsElement (list): list of all grains element type

  2. grainsWeight (list): list of all grains weight which is relative or equal to the number of atoms in a grain

  3. moleculesIndex (list): list of grains molecule index

  4. subframesIndex (list): list of grains subframe index that refers to the subframe from where the grain atoms are found

  5. coordinates (numpy.ndarray): grains real coordinates

set_groups_as_subframes(name=None, add=False)

Helper method to automatically to create groups of subframe atom indexes. If add is True, created groups will be added to engine existing ones otherwise old groups will be removed.

Parameters:
  1. name (None, string, list): groups name. If string is given, the same name will be given to all groups. If list is given, it must have the same length as the number of molecules in the system. If None is given, names will be set as subframe name

  2. add (boolean): whether to add newly generated groups to old ones

set_distance_constraint(defaultLowerDistance=None, pairsDefinition=None)

Create and set grains inter-frames distance constraint. All given distances will be adjusted to system given grainSize per elements pair.

Parameters:
  1. defaultLowerDistance (None, number): The default lower distance allowed. If None, defaultLowerDistance will be set to 1.5. Final defaultLowerDistance will be defaultLowerDistance + 2*grainSize

  2. pairsDefinition (None, list, dict): list where items are lists or tuples of 3 items (first element, second element, lower distance). All distances will be automatically adjusted by adding grainSize

GE.set_distances_constraint(defaultLowerDistance=2.,
                           pairsDefinition={('h','c'):2.5, ('h','o'):2.75})

# constraint pairs distances for ('h','c') pair will be automatically
# adjusted to 'h' and 'c' grain sizes. Therefore ('h','c') distance
# will be set to 2.5 + h_grainSize + c_grainSize accounting for
# the maximum width of both grains. Similarly ('h','o') pairs
# distance will be adjusted and all other pairs
set_experimental_constraints()

Set engine experimental constraints cloning those given in multiframe structure

run(numberOfSteps=100000, resetLoss=False, updateLoss=True, optimize=True, sortConstraints=True)

Run method for Grains_Engine

Previous topic

The Problem That Led to fullrmc

Next topic

fullrmc.Globals module