pyretis.initiation package¶
This package defines methods for initiating path ensembles.
Package structure¶
Modules¶
- __init__.py
This file, imports from the other modules and defines some helper methods for the initiation.
- initiate_kick.py (
pyretis.initiation.initiate_kick) Methods for initiating using the
kickmethod.- initiate_load.py (
pyretis.initiation.initiate_load) Methods for initiating by loading already existing paths from files.
- initiate_restart.py (
pyretis.initiation.initiate_restart) Methods for initiating by loading PyRETIS restart files.
Important methods defined in this package¶
- get_initiation_method (
get_initiation_method()) Method to select initiation method from settings.
- initiate_path_simulation (
initiate_path_simulation()) Method to initiate a path simulation.
- pyretis.initiation.get_initiation_method(settings)[source]¶
Return the initiation method from given settings.
- Parameters:
settings (dict) – This dictionary contains the settings for the initiation.
- Returns:
out (callable) – The method to be used for the initiation.
- pyretis.initiation.initiate_path_simulation(simulation, settings)[source]¶
Initialise a path simulation.
- Parameters:
simulation (object like
PathSimulation) – The simulation we are doing the initiation for.settings (dict) – A dictionary with settings for the initiation.
- Returns:
out (callable) – The method to be used for the initiation.
List of submodules¶
pyretis.initiation.initiate_kick module¶
This file contains functions used for initiation of paths.
Important methods defined here¶
- generate_initial_path_kick (
generate_initial_path_kick()) Function for generating an initial path by repeatedly kicking a phase point.
- initiate_kick (
initiate_kick()) Helper method, selects either
initiate_kicki()orinitiate_kick_max().- initiate_kicki (
initiate_kicki()) A method for initiating a path ensemble by repeatedly modifying velocities to find the crossing with the interfaces.
- initiate_kick_max (
initiate_kick_max()) A method similar to py:meth:.initiate_kick. Here, if possible, we will use points from the previous paths, closest to the target interface.
- initiate_path_ensemble_kick (
initiate_path_ensemble_kick()) Method to initiate a single path ensemble.
- fix_path_by_tis (
fix_path_by_tis()) Method to fix an initial path that starts and ends at the wrong interface via TIS moves.
- pyretis.initiation.initiate_kick.fix_path_by_tis(initial_path, ensemble, tis_settings)[source]¶
Fix a path that starts and ends at the wrong interfaces.
The given path is amended by performing TIS moves (shooting and time reversal). Note that this function is intended to be used in connection with the initialisation.
- Parameters:
initial_path (object like
PathBase) – This is the initial path to fix. It starts & ends at the wrong interface.ensemble (dict.) – It contains:
path_ensemble : object like
PathEnsembleThe path ensemble to create an initial path for.system : object like
SystemSystem is used here since we need access to the temperature and to the particle list.order_function : object like
OrderParameterThe class used for obtaining the order parameter(s).engine : object like
EngineBaseThe engine to use for propagating a path.rgen : object like
RandomGeneratorThis is the random generator that will be used.
tis_settings (dict) – Settings for TIS method, here we explicitly use:
start_cond: string which defines the start condition.
maxlength: integer which gives the maximum allowed path length.
Note that we here explicitly set some local TIS settings for use in the make_tis_step function.
- Returns:
out (object like
PathBase) – The amended path.
- pyretis.initiation.initiate_kick.generate_initial_path_kick(ensemble, tis_settings)[source]¶
Generate an initial path with the kicking method.
This function will generate an initial path by repeatedly kicking a phase-space point until the middle interface is crossed. The point before and after kicking are stored, so when the middle interface is crossed we have two points we can integrate forward and backward in time. This function is intended for use with TIS. For use with RETIS one should set the appropriate tis_settings so that the starting conditions are fine (i.e. for the [0^-] ensemble it might be different for the other ensembles).
- Parameters:
ensemble (dict.) – It contains:
path_ensemble : object like
PathEnsembleThe path ensemble to create an initial path for.system : object like
SystemSystem is used here since we need access to the temperature and to the particle list.order_function : object like
OrderParameterThe class used for obtaining the order parameter(s).engine : object like
EngineBaseThe engine to use for propagating a path.rgen : object like
RandomGeneratorThis is the random generator that will be used.
tis_settings (dict) – This dictionary contains settings for TIS. Explicitly used here:
start_cond: string, starting condition, ‘L’eft or ‘R’ight.
maxlength: integer, maximum allowed length of paths.
- Yields:
out[0] (boolean) – True if we are finished.
out[1] (string) – The current status of this method.
out[2] (object like
PathBaseor None) – If we are finished (and successful) this is the generated initial path. Otherwise, this is equal to None.
- pyretis.initiation.initiate_kick.initiate_kick(simulation, settings, cycle)[source]¶
Run the initiation method for several ensembles.
Please see documentation for
initiate_path_ensemble_kick().
- pyretis.initiation.initiate_kick.initiate_kick_max(simulation, settings, cycle)[source]¶
Run the initiation for several ensembles.
This method is similar to
initiate_kick(), but here we update the initial point for an ensemble to use that of the previous path (if this exists).Please see documentation for
initiate_path_ensemble_kick().
- pyretis.initiation.initiate_kick.initiate_kicki(simulation, settings, cycle)[source]¶
Run the initialization for several ensembles.
Please see documentation for
initiate_path_ensemble_kick().
- pyretis.initiation.initiate_kick.initiate_path_ensemble_kick(ensemble, tis_settings, cycle)[source]¶
Run the “kick” initiate for a given ensemble.
- Parameters:
ensemble (dict) – It contains:
path_ensemble : object like
PathEnsembleThe path ensemble to create an initial path for.system : object like
SystemThe system is used here since we need access to the temperature and to the particle list.order_function : object like
OrderParameterThe class used for obtaining the order parameter(s).engine : object like
EngineBaseThe engine to use for propagating a path.rgen : object like
RandomGeneratorThis is the random generator that will be used.
tis_settings (dict) – This dictionary contains the TIS settings.
cycle (integer, optional) – The cycle number we are initiating at, typically this will be 0 which is the default value.
- Returns:
out[0] (boolean) – True if the initial path was accepted.
out[1] (object like py:class:.PathBase) – The initial path.
out[2] (string) – The status of the path.
- pyretis.initiation.initiate_kick.run_parallel_kick_job(kick_item, engine_pool)[source]¶
Run kick initiation for ONE ensemble inside a scheduler worker.
This is the worker-side counterpart of
initiate_path_ensemble_kick(), used by the infinite-swapping scheduler’s parallel kick phase (one job per ensemble, dispatched across the worker pool) instead of the sequential, single-processpyretis.inout.config_adapter.generate_load_dir(). It resolves this job’s engine from the worker’s process-local engine pool, builds a throwawayPathEnsemble/PathEnsembleExt+ensembledict matching the shapeinitiate_path_ensemble_kick()expects, and calls it unmodified – so the kick algorithm itself (greedy hill-climb, retry/reverse/fix-by-TIS-moves validity checks) is not duplicated or re-implemented here.- Parameters:
kick_item (dict) – One ensemble’s kick job. Keys:
ens_num : int, the ensemble index (0-based, coordinator numbering).
eng_name : string, the engine name to resolve from
engine_pool.interfaces : list of floats,
[left, middle, right].start_cond : string or list of strings, the ensemble’s start condition (overrides the constructor’s own ensemble-number-based default – the scheduler’s per-route value is the source of truth).
must_cross_M : boolean, the PPTIS/REPPTIS body-ensemble invariant (see
generate_initial_path_kick()).tis_settings : dict, the TIS settings for this ensemble.
system : object like
System, the starting phase point (a fresh copy is taken; the caller’s copy is not mutated).run_dir : string, the base directory under which this ensemble’s working directories are created.
engine_rgen : object like
RandomGenerator, the engine’s integration random generator.kick_rgen : object like
RandomGenerator, the velocity-kick random generator.path_rgen : object like
RandomGenerator, the path-ensemble’s own random generator.
engine_pool (dict) – This worker’s process-local engine pool (from
pyretis.simulation.async_runner.get_worker_engines()), keyed by engine name.
- Returns:
dict –
{'ens_num': ..., 'path': initial_path, 'status': status}.
pyretis.initiation.initiate_load module¶
Method for initiating paths by loading from previous simulation(s).
Important methods defined here¶
- initiate_load (
initiate_load()) A method that will get the initial path from the output of a previous simulation.
- pyretis.initiation.initiate_load._check_path(path, path_ensemble, warning=True)[source]¶
Run some checks for the path.
- Parameters:
path (object like
PathBase) – The path we are to set up/fill.path_ensemble (object like
PathEnsemble) – The path ensemble the path could be added to.warning (boolean, optional) – If True, it output warnings, else only debug info.
- pyretis.initiation.initiate_load._do_the_dirty_load_job(mainfolder, edir)[source]¶
Copy the files to a place where PyRETIS expects them to be.
The function checks if in the destination folder some suitable files are already present. If not, it tries to copy them from the main load folder.
- Parameters:
mainfolder (string) – The path of the main load directory with frame/trajectory files.
edir (string) – The path of the path ensemble load directory with frame/trajectory files.
- pyretis.initiation.initiate_load.clean_path(path, path_ensemble, simtype='retis')[source]¶
Remove useless frames from a path.
This function removes phasepoints from a path that are not needed (e.g. the one in stable states)
- Parameters:
path (object like
PathBase) – The path we try to fix.path_ensemble (object like
PathEnsembleExt) – The path ensemble the path could be added to.simtype (string) – The simulation type. ‘retis’, ‘repptis’, ‘pptis’
- pyretis.initiation.initiate_load.initiate_load(simulation, settings, cycle, plot_loads=False)[source]¶
Initialise paths by loading already generated ones.
- Parameters:
simulation (object like
Simulation) – The simulation we are setting up.cycle (integer) – The simulation cycles we are starting at.
settings (dictionary) – A dictionary with settings for the initiation.
- pyretis.initiation.initiate_load.read_path_files(path, dirname, ensemble)[source]¶
Read data needed for a path from a directory.
- Parameters:
path (object like
PathBase) – The path we are to set up/fill.dirname (string) – The path to the directory with the input files.
ensemble (dictionary of objects) – It contains:
path_ensemble: object like
PathEnsembleThis is the path ensemble to perform the initialization.order_function: object like
OrderParameterThe class used for obtaining the order parameter(s).engine: object like
EngineBaseThe engine to use for propagating a path.system: object like
SystemA system object we can use when calculating the order parameter(s).
- pyretis.initiation.initiate_load.read_path_files_ext(path, dirname, ensemble)[source]¶
Read data needed for a path from a directory.
- Parameters:
path (object like
Path) – The path we are to set up/fill.path_ensemble (object like
PathEnsembleExt) – The path ensemble the path could be added to.dirname (string) – The path to the directory with the input files.
ensemble (dictionary of objects) – It contains:
path_ensemble: object like
PathEnsembleThis is the path ensemble to perform the initialization.order_function: object like
OrderParameterThe class used for obtaining the order parameter(s).engine: object like
EngineBaseThe engine to use for propagating a path.system: object like
SystemA system object we can use when calculating the order parameter(s).
- pyretis.initiation.initiate_load.reorderframes(path, path_ensemble)[source]¶
Re-order the phase points in the input path.
This function assumes that the path needs to be fixed. It checks for the validity of the path and keeps only the frames that are useful for the region to explore e.g. [0^-].
- Parameters:
path (object like
PathBase) – The path we try to fix.path_ensemble (object like
PathEnsembleExt) – The path ensemble the path could be added to.
pyretis.initiation.initiate_restart module¶
This file contains functions used for initiation of paths.
Important methods defined here¶
- initiate_restart (
initiate_restart()) A method that will get the initial path from the output from a previous simulation.
- pyretis.initiation.initiate_restart.initiate_restart(simulation, settings, cycle)[source]¶
Initialise paths by loading restart data.
- Parameters:
simulation (object like
Simulation) – The simulation we are setting up.settings (dictionary) – A dictionary with settings for the initiation.
cycle (integer) – The simulation cycles we are starting at.