Cyclus Library Bindings (cyclus.lib)

Python wrapper for cyclus.

class cyclus.lib.Agent

The abstract base class used by all types of agents that live and interact in a simulation.

annotations

Agent annotations.

schema

An agent’s xml rng schema for initializing from input files. All concrete agents should override this function. This must validate the same xml input that the InfileToDb function receives.

version

Agent version string.

class cyclus.lib.AgentSpec

AgentSpec C++ wrapper

Parameters:

spec : str or None, optional

This repesents either the full string form of the spec or just the path.

lib : str or None, optional

agent : str or None, optional

alias : str or None, optional

agent
alias
lib
path
sanatize()
class cyclus.lib.Context

A simulation context provides access to necessary simulation-global functions and state. All code that writes to the output database, needs to know simulation time, creates/builds facilities, and/or uses loaded composition recipes will need a context pointer. In general, all global state should be accessed through a simulation context.

Parameters:

timer : Timer, optional

An instance of the timer class.

recorder : Recorder, optional

An instance of the recorder class.

init : bool, optional

Whether or not to initialize a new context object.

Warning

  • The context takes ownership of and manages the lifetime/destruction of all agents constructed with it (including Cloned agents). Agents should generally NEVER be allocated on the stack.
  • The context takes ownership of the solver and will manage its destruction.
del_agent()

Destructs and cleans up an agent (and it’s children recursively).

sim_id

The simulation ID.

class cyclus.lib.Datum

Datum class.

add_val()

Adds Datum value to current record as the corresponding cyclus data type.

Parameters:

field : str or bytes

The column name.

value : object

Value in table column.

shape : list or tuple of ints

Length of value.

dbtype : cpp data type

Data type as defined by cyclus typesystem

Returns:

self : Datum

record()

Records the Datum.

title

The datum name.

class cyclus.lib.DynamicModule

Dynamic Module wrapper class.

close_all()

Closes all dynamic modules.

exists()

Tests whether an agent spec exists.

make()

Returns a newly constructed agent for the given module spec.

Returns:rtn : Agent
path
class cyclus.lib.Env

Environment wrapper class.

An environment utility to help locate files and find environment settings. The environment for a given simulation can be accessed via the simulation’s Context.

allow_milps

whether or not Cyclus should allow Mixed-Integer Linear Programs The default depends on a compile time option DEFAULT_ALLOW_MILPS, but may be specified at run time with the ALLOW_MILPS environment variable.

build_path

The Cyclus build path.

cyclus_path

A tuple of strings representing where cyclus searches for modules.

env_delimiter

the correct environment variable delimiter based on the file system.

find_module()

Returns the full path to a module by searching through default install and CYCLUS_PATH directories.

get()

Obtains an environment variable.

install_path

The Cyclus install path.

nuc_data

The nuc_data path.

path_base()

Effectively basename

path_delimiter

the correct path delimiter based on the file system.

rng_schema()

Returns the current rng schema. Uses CYCLUS_RNG_SCHEMA env var if set; otherwise uses the default install location. If using the default ocation, set flat=True for the default flat schema.

set_nuc_data_path()

Initializes the path to the cyclus_nuc_data.h5 file

By default, it is assumed to be located in the path given by GetInstallPath()/share; however, paths in environment variable CYCLUS_NUC_DATA are checked first.

class cyclus.lib.FullBackend

Full backend cyclus database interface.

query()

Queries a database table.

Parameters:

table : str

The table name.

conds : iterable, optional

A list of conditions.

Returns:

results : pd.DataFrame

Pandas DataFrame the represents the table

tables

Retrieves the set of tables present in the database.

class cyclus.lib.Hdf5Back

HDF5 backend cyclus database interface.

close()

Closes the backend, flushing it in the process.

flush()

Flushes the database to disk.

name

The name of the database.

query()

Queries a database table.

Parameters:

table : str

The table name.

conds : iterable, optional

A list of conditions.

Returns:

results : pd.DataFrame

Pandas DataFrame the represents the table

tables

Retrieves the set of tables present in the database.

class cyclus.lib.InfileTree

A class for extracting information from a given XML parser

Parameters:

parser : XMLParser

An XMLParser instance.

optional_query()

A query method for optional parameters.

Parameters:

query : str

The XML path to test if it exists.

default : any type

The default value to return if the XML path does not exist in the tree. The type of the return value (str, bool, int, etc) is determined by the type of the default.

class cyclus.lib.Logger

A logging tool providing finer grained control over standard output for debugging and other purposes.

no_agent

Set whether or not agent/agent log entries should be printed

no_mem
report_level

Use to get/set the (global) log level report cutoff.

to_log_level()

Converts a string into a corresponding LogLevel value.

For strings that do not correspond to any particular LogLevel enum value the method returns the LogLevel value LEV_ERROR. This method is primarily intended for translating command line verbosity argument(s) in appropriate report levels. LOG(level) statements

to_string()

Converts a LogLevel enum value into a corrsponding string.

For a level argments that have no corresponding string value, the string BAD_LEVEL is returned. This method is primarily intended for translating LOG(level) statement levels into appropriate strings for output to stdout.

class cyclus.lib.Recorder

Cyclus recorder interface.

close()

Closes the recorder.

dump_count

The frequency of recording.

flush()

Flushes the recorder to disk.

inject_sim_id

Whether or not to inject the simulation id into the tables.

new_datum()

Registers a backend with the recorder.

register_backend()

Registers a backend with the recorder.

sim_id

The simulation id of the recorder.

class cyclus.lib.SimInit

Handles initialization of a simulation from the output database. After calling Init, Restart, or Branch, the initialized Context, Timer, and Recorder can be retrieved.

Parameters:

recorder : Recorder

The recorder class for the simulation.

backend : QueryableBackend

A backend to use for this simulation.

context

Returns the initialized context. Note that either Init, Restart, or Branch must be called first.

timer

Returns the initialized timer. Note that either Init, Restart, or Branch must be called first.

class cyclus.lib.SqliteBack

SQLite backend cyclus database interface.

close()

Closes the backend, flushing it in the process.

flush()

Flushes the database to disk.

name

The name of the database.

query()

Queries a database table.

Parameters:

table : str

The table name.

conds : iterable, optional

A list of conditions.

Returns:

results : pd.DataFrame

Pandas DataFrame the represents the table

tables

Retrieves the set of tables present in the database.

class cyclus.lib.Timer

Controls simulation timestepping and inter-timestep phases.

Parameters:

init : bool, optional

Whether or not we should initialize a new C++ Timer instance.

run_sim()

Runs the simulation.

class cyclus.lib.XMLFileLoader

Handles initialization of a database with information from a cyclus xml input file.

Create a new loader reading from the xml simulation input file and writing to and initializing the backends in the recorder. The recorder must already have the backend registered. schema_file identifies the master xml rng schema used to validate the input file.

load_sim()

Load an entire simulation from the inputfile.

class cyclus.lib.XMLFlatLoader

Handles initialization of a database with information from a cyclus xml input file.

Create a new loader reading from the xml simulation input file and writing to and initializing the backends in the recorder. The recorder must already have the backend registered. schema_file identifies the master xml rng schema used to validate the input file.

Notes

This is not a subclass of the XMLFileLoader Python bindings, even though the C++ class is a subclass in C++. Rather, they are duck typed by exposing the same interface. This makes handling the instance pointers in Cython a little easier.

load_sim()

Load an entire simulation from the inputfile.

class cyclus.lib.XMLParser

A helper class to hold xml file data and provide automatic validation.

Parameters:

filename : str, optional

Path to file to load.

raw : str, optional

XML string to load.

cyclus.lib.boost_version()

Boost version.

cyclus.lib.coincbc_version()

Coin CBC version.

cyclus.lib.coinclp_version()

Coin CLP version.

cyclus.lib.core_version()

Cyclus core version.

cyclus.lib.describe_version()

Describes the Cyclus version.

cyclus.lib.discover_metadata_in_cyclus_path()

Discover archetype metadata in cyclus path. Returns a Jason.Value object.

cyclus.lib.discover_specs()

Discover archetype specifications for a path and library. Returns a set of strings.

cyclus.lib.discover_specs_in_cyclus_path()

Discover archetype specifications that live recursively in CYCLUS_PATH directories. Returns a set of strings.

cyclus.lib.get_warn_as_error()

Returns the current value for wether warnings should be treated as errors.

cyclus.lib.get_warn_limit()

Returns the current warning limit.

cyclus.lib.hdf5_version()

HDF5 version.

cyclus.lib.json_to_py()

Converts a JSON string into an equivalent Python string

cyclus.lib.json_to_xml()

Converts a JSON string into an equivalent XML string

cyclus.lib.load_string_from_file()

Loads an XML file from a path.

cyclus.lib.py_init_hooks()

Initializes Cyclus-internal Python hooks. This is called automatically when cyclus is imported. Users should not need to call this function.

cyclus.lib.py_to_json()

Converts a Python string into an equivalent JSON string

cyclus.lib.py_to_xml()

Converts a Python string into an equivalent XML string

cyclus.lib.set_warn_as_error()

Sets whether warnings should be treated as errors.

cyclus.lib.set_warn_limit()

Sets the warning limit.

cyclus.lib.sqlite3_version()

SQLite3 version.

cyclus.lib.version()

Returns string of the cyclus version and its dependencies.

cyclus.lib.xml2_version()

libxml 2 version.

cyclus.lib.xml_to_json()

Converts an XML string into an equivalent JSON string

cyclus.lib.xml_to_py()

Converts an XML string into an equivalent Python string

cyclus.lib.xmlpp_version()

libxml++ version.