idaes package

__init__.py for idaes module

Set up logging for the idaes module, and import plugins.

Subpackages

Submodules

idaes.config module

idaes.config.create_dir(d)[source]

Create a directory if it doesn’t exist.

Parameters:d (str) – directory path to create
Retruns:
None
idaes.config.import_packages(packages, optional=True)[source]

Import plugin package, condensed from pyomo.environ.__init__.py :param packages: list of packages in which to look for plugins :param optional: true, log ImportError but continue; false, raise if ImportError

Returns:None
idaes.config.read_config(read_config, write_config)[source]

Read either a TOML formatted config file or a configuration dictionary. :param config: A config file path or dict

Returns:None

idaes.logger module

idaes.logger.condition(res)[source]

Get the solver termination condition. Since it seems to be common to have an if block to check for None if the solver call raised a handled exception

idaes.logger.getIdaesLogger(name, level=None)[source]

Return an idaes logger.

Parameters:
  • name – usually __name__
  • level – standard IDAES logging level (default use IDAES config)
Returns:

logger

idaes.logger.getInitLogger(name, level=None)[source]

Get a model initialization logger

Parameters:
  • name – Object name (usually Pyomo Component name)
  • level – Logging detail level (for initialization routines 1 to 6) * 0 = Use default idaes.init logger setting * 1 = Maximum output * 2 = Include solver output * 3 = Return solver state for each step in subroutines * 4 = Return solver state for each step in routine * 5 = Final initialization status and exceptions * 6 = No output
Returns:

logger

idaes.logger.getModelLogger(name, level=None)[source]

Get a logger for an IDAES model. This function helps users keep their loggers in a standard location and using the IDAES logging config.

Parameters:
  • name – Name (usually __name__). Any starting ‘idaes.’ is stripped off, so if a model is part of the idaes package, idaes won’t be repeated.
  • level – Standard Python logging level (default use IDAES config)
Returns:

logger

idaes.logger.init_tee(logger, tee_level=2)[source]

Function to use in initialization to determine at a given output level whether to use the sovler tee option to print solver output. This function just helps standardize the level for solver output to appear and make the initialization routine code a bit cleaner.

Parameters:
  • logger – logger to get output level from
  • tee_level – Level at which to show solver output, usually use default
Returns
(bool)
idaes.logger.solver_tee(logger, tee_level=10)[source]

Function to produce solver output based on the logging level of a specific logger. This function just helps standardize the level for solver output to appear and make code a bit cleaner.

Parameters:
  • logger – logger to get output level from
  • tee_level – Level at which to show solver output, usually use default
Returns
(bool)

idaes.solvers module

idaes.solvers.download_binaries(url=None, verbose=False)[source]

Download IDAES solvers and libraries and put them in the right location. Need to supply either local or url argument.

Parameters:url (str) – a url to download binary files to install files
Returns:None

idaes.ver module

The API in this module is mostly for internal use, e.g. from ‘setup.py’ to get the version of the package. But Version has been written to be usable as a general versioning interface.

Example of using the class directly:

>>> from idaes.ver import Version
>>> my_version = Version(1, 2, 3)
>>> print(my_version)
1.2.3
>>> tuple(my_version)
(1, 2, 3)
>>> my_version = Version(1, 2, 3, 'alpha')
>>> print(my_version)
1.2.3.a
>>> tuple(my_version)
(1, 2, 3, 'alpha')
>>> my_version = Version(1, 2, 3, 'candidate', 1)
>>> print(my_version)
1.2.3.rc1
>>> tuple(my_version)
(1, 2, 3, 'candidate', 1)

If you want to add a version to a class, e.g. a model, then simply inherit from HasVersion and initialize it with the same arguments you would give the Version constructor:

>>> from idaes.ver import HasVersion
>>> class MyClass(HasVersion):
...     def __init__(self):
...         super(MyClass, self).__init__(1, 2, 3, 'alpha')
...
>>> obj = MyClass()
>>> print(obj.version)
1.2.3.a
class idaes.ver.HasVersion(*args)[source]

Interface for a versioned class.

class idaes.ver.Version(major, minor, micro, releaselevel='final', serial=None, label=None)[source]

This class attempts to be compliant with a subset of PEP 440.

Note: If you actually happen to read the PEP, you will notice that pre- and post- releases, as well as “release epochs”, are not supported.

idaes.ver.git_hash()[source]

Get current git hash, with no dependencies on external packages.

idaes.ver.package_version = <idaes.ver.Version object>

Package’s version as an object