chemapp.friendly

This module provides a friendly Python interface to the ChemApp library.

The friendly module uses static classes and descriptive names to to make the interface clear, easy to read, and easy to remember.

Static Classes

These classes are simply containers that group related methods together to make it easier to think about, remember, and use the interface. It is not possible to instantiate these classes, i.e. you cannot create objects from them.

The following static classes are provided in the friendly interface:

  • Info

    You can use this class to get information about ChemApp itself, its license, user name, expiry date, array sizes, etc.

  • Units

    You can use this class to get and set the units used by ChemApp.

  • ThermochemicalSystem

    With this class you can get information about the current thermochemical system that was read from a data file.

  • EquilibriumCalculation

    You can use this class to do standard equilibrium calculations. ‘Standard’ means that the calculation does not use streams, and it also does not do phase map calculations. These calculations are absolute, which means that you can calculate Cp, H, S, G, and V for a system, but no not \Delta ext{Cp}, \Delta ext{H}, \Delta ext{S}, \Delta ext{G}, or \Delta ext{V}.

  • StreamCalculation

    You can use this class to do equilibrium calculations that take streams as inputs. You can combine ore, reductant, and flux streams, for example. With these calculations you can calculate both absolute and relative values of thermodynamic properties (Cp, H, S, G, V; and \Delta ext{Cp}, \Delta ext{H}, \Delta ext{S}, \Delta ext{G}, \Delta ext{V}).

  • PhaseMapCalculation

    This class assist with doing one-dimensional phase map calculations. These calculations are useful for finding phase boundaries.

Additionally, these classes exist for technical reasons and internal use.

  • EquilibriumCalculationBase (abstract)

    This is an abstract class, and you should not use it directly. It is a base class of the EquilibriumCalculation, StreamCalculation, and PhaseMapCalculation classes, and provides methods used by all of them.

  • AbsoluteEquilibriumCalculationBase (abstract)

    This is an abstract class, and you should not use it directly. It is a base class of the EquilibriumCalculation, and PhaseMapCalculation classes, and provides methods used by them.

Descriptive Naming

The friendly module uses longer names for parameters and functions than ChemApp itself. The aim is to make these names easier to read, remember and use.

The following abbreviations are used in the interface to name functions, parameters, etc.:

Abbreviation

Term

Abbreviation

Quantity

cf

complex formula

CP

heat capacity

cfs

complex formulae

E

energy

eq

equilibrium

G

Gibbs energy

mm

molar mass

H

enthalpy

ph

phase

IA

incoming amount

phs

phases

MU

chemical potential

pc

phase constituent

P

pressure

pcs

phase constituents

S

entropy

sc

system component

T

temperature

scs

system components

V

volume

st

stream

VT

total volume

sts

streams

X

fraction

tg

target

XT

mole fraction

tx

transition

y

mass fraction

txs

transitions

Module Contents

Classes

AmountUnit

Available amount units.

ChemAppError

Errors generated by the ChemApp API's standard error reporting mechanism.

ChemAppInfo

This class provides information about ChemApp.

ChemicalFormulaIncomingAmountState

This class represents the state of a chemical formula incoming amount in

Composition

Represents a Composition, which is essentially a {element:amount} mapping

ConditionVariable

Available variables for setting conditions in equilibrium calculations.

ConfigurationOption

Configuration options for ChemApp.

EnergyUnit

Available energy units.

EquilibriumCalculationResult

An object of this class stores all the results of a single equilbrium

InteractionVariable

Enum to specific the type of interaction parameter to extract.

IoOption

Input/output options used by tqgio() and

PhaseConfig

This class represents the configuration of a phase as read from a

PhaseConstituentConfig

This class represents the configuration of a phase constituent as read from

PhaseConstituentData

Available data items that can be requested for phase constituents.

PhaseConstituentIncomingAmountState

This class represents the state of an phase constituent incoming amount in

PhaseConstituentState

This class represents the state of a phase constituent in an equilibrium

PhaseConstituentVariable

Available variables for extracting thermodynamic properties of phase

PhaseMapVariable

Variables that can be used to adjust conditions as part of phase map

PhaseState

This class represents the state of a phase in an equilibrium calculation

PressureUnit

Available pressure units.

Quantity

Quantities available for setting units.

ResultVariable

Result variables available after equilibrium calculations.

SolutionModel

Available solution models.

Status

Status values for phases and phase constituents.

StreamCalculationResult

See EquilibriumCalculationResult

StreamState

This class represents the state of a stream used as input to a stream

StreamVariable

Available variables for stream properties that can be extracted.

SystemComponentConfig

This class represents the configuration of a system component as read from a

SystemComponentIncomingAmountState

This class represents the state of a system component incoming amount in

SystemComponentState

This class represents the state of a system component in an equilibrium

TargetVariable

Variables that can be used in target calculations to arrive at a specified

TemperatureUnit

Available temperature units.

ThermochemicalSystemConfig

An object of this class stores all the information about a thermochemical

VolumeUnit

Available volume units.

AbsoluteEquilibriumCalculationBase

This abstract class provides base functionality for absolute equilibrium

EquilibriumCalculation

This class provides facilities to perform normal (non-stream, non-phase

EquilibriumCalculationBase

This class provides base functionality share between all equilibrium

Info

This class provides access to ChemApp functions that are used to get

PhaseMapCalculation

This abstract class provides base functionality for absolute equilibrium

StreamCalculation

This class provides base functionality share between all equilibrium

ThermochemicalSystem

This class provides access to ChemApp functions that are used to perform

Units

This class provides access to ChemApp functions that are used to perform

Functions

switch_components(composition, components[, tol, ...])

Determine the stoichiometric factors for a composition given a set of

class chemapp.friendly.AmountUnit

Bases: enum.Enum

Available amount units.

Amount

mol

gram

kg

tonne

pound

class chemapp.friendly.ChemAppError

Bases: ChemAppPyError

Errors generated by the ChemApp API’s standard error reporting mechanism.

It is possible to acquire the ChemApp error number via the errno property. If this is not applicable, it will return 0.

property errno: int

<int> The error number of ChemApp, if applicable. Defaults to 0.

Return type:

int

class chemapp.friendly.ChemAppInfo

Bases: Object

This class provides information about ChemApp.

property array_size_descriptions

Get the array size descriptions of ChemApp’s memory setup.

property array_sizes_max

Get the maximum array sizes of ChemApp.

property array_sizes_used

Get the currently used array size descriptions of ChemApp.

property copyright

Get the copyright message of ChemApp.

property dongle_id

Get the dongle ID.

property dongle_type

Get the dongle type.

property expiration_date

Get the ChemApp expiration date.

property is_light

Get if the light version of ChemApp is used.

property program_id

Get the ChemApp program id.

property user_id

Get the user id.

property user_name

Get the user name.

property version

Get the ChemApp version.

exception chemapp.friendly.ChemAppPyError

Bases: Exception

Base class for all errors related to the ChemApp python package.

class chemapp.friendly.ChemicalFormulaIncomingAmountState

Bases: IncomingAmountState

This class represents the state of a chemical formula incoming amount in an equilibrium calculation result.

Parameters:
  • cf (str) – chemical formula

  • A (float) – amount value

property A: float

Amount.

Returns:

Amount

Return type:

float

property cf: str

Chemical formula name.

Returns:

chemical formula

Return type:

str

property scs: List[str]

System components present in the chemical formula.

Returns:

System components in the chemical formula

Return type:

List[str]

property scs_A: Dict[str, float]

System components and amounts in the chemical formula.

Returns:

calculated system component amounts

Return type:

Dict[str, float]

class chemapp.friendly.Composition

Represents a Composition, which is essentially a {element:amount} mapping

It can be parsed from a string representation of a composition. Some examples: “Fe2O3”, “Sr(OH)3”, “H2O”, “LiPO4”.

It can also be created as a copy of another Composition class, or from a dictionary of elements:amounts mappings. For consistency reasons, the order of the elements is preserved as entered.

Parameters:

*args (str | Composition | Dict[str,float]) – The composition to create.

property elements: FrozenSet[str]

The elements the composition contains.

Returns:

element set

Return type:

FrozenSet[str]

property formula: str

String representation of the composition.

This gives the formula after internal parsing. It may be differently formatted compared to the input formula.

Examples

>>> Composition("H20").formula
'H20'
>>> Composition("Cs(OH)3").formula
'Cs1O3H3'
Returns:

printable composition

Return type:

str

property num_atoms: float

Get the number of atoms in the formula.

Returns:

sum of all constituent atom amounts

Return type:

float

property pretty_formula: str

Get the pretty formula of the composition

Elements sorted by Pauling order. No grouping of functional groups. If an element has the amount equal to 1, that number is omitted.

Returns:

printable composition

Return type:

str

property pretty_reduced_formula: str

Get the pretty reduced formula of the composition

Elements sorted by Pauling order. No grouping of functional groups. Smallest common denominator applied to the element composition.

Returns:

printable composition

Return type:

str

property reduced_formula: str

Get the reduced formula of the composition

Smallest common denominator applied to the element composition.

Returns:

printable composition

Return type:

str

property unordered: Dict[str, float]

Get the as entered order of elements.

Returns:

elemental composition

Return type:

Dict[str, float]

to_dict(reduced=False)

Get the composition as dictionary {element:amount}.

Parameters:

reduced – (default: False) Whether the smallest applicable scaling factor is applied.

Return type:

Dict[str, float]

Examples

>>> Composition("Fe4O6").to_dict()
{"Fe": 4.0, "O": 6.0}
>>> Composition("Fe4O6").to_dict(reduced=True)
{"Fe": 2.0, "O": 3.0}
Returns:

Dictionary of {element:amount} of the composition

Return type:

Dict[str, float]

class chemapp.friendly.ConditionVariable

Bases: enum.Enum

Available variables for setting conditions in equilibrium calculations.

Value

Variable

Description

P

Total pressure

Last entered (pressure or volume) takes precedence. Default value is 1 bar.

VT

Total volume

Last entered (pressure or volume) takes precedence. Note that the use of this option to perform calculations at constant volume is discouraged, see Appendix B.4 for details.

T

Temperature

Default value is 1000 K.

A

Amount of phase

VAL >=0 defines a formation target calculation; VAL <0 a precipitation target calculation for a mixture phase. In a formation target calculation, the target variable is varied until unit activity and zero amount of the target phase is achieved. A precipitation target is defined as one where the target phase is the only one formed at equilibrium, and the second most stable phase has unit activity.

IA

Incoming amount

Valid for phase constituents and system components. Not permitted for TQSTEC.

MU

Chemical potential

Valid only for phase constituents. Not permitted for TQSTEC.

AC

Relative activity,

Valid only for phase constituents. Not permitted for TQSTEC.

CP, H, S, G, V,

Heat capacity, Enthalpy, Entropy, Gibbs energy, Volume

Valid for the entire system or for a phase. Extensive properties are either calculated for the equilibrium phases and are then dependent on the reference state chosen in the data-file, or for the chemical reaction when streams are defined, in which case they are relative to the state defined by the stream conditions.

AT

Relative activity

Relative activity of a phase constituent as target.

XT

Mole fraction

Mole fraction of a phase constituent as target.

XPT

Mole fraction

Mole fraction of a system component in a phase as target.

class chemapp.friendly.ConfigurationOption

Bases: enum.Enum

Configuration options for ChemApp.

Parameters:

E – The electron configuration option.

class chemapp.friendly.EnergyUnit

Bases: enum.Enum

Available energy units.

Energy

J

cal

Btu

kWh

class chemapp.friendly.EquilibriumCalculationResult

Bases: ConvertableObject

An object of this class stores all the results of a single equilbrium calculation result, regardless of the type of calculation (normal, stream, phase map).

Parameters:
  • units (Dict[str, PressureUnit | VolumeUnit | TemperatureUnit | EnergyUnit | AmountUnit]) – units as returned by Units.get()

  • ts_md5 (str) – md5 checksum of the thermochemical data file that the result is based on

  • t_start (float) – calculation start timestamp

  • t_end (float) – calculation end timestamp

  • dt (float) – calculation time

property IAs: List[IncomingAmountState]

The specified or calculated incoming amounts.

Returns:

incoming amounts

Return type:

List[IncomingAmountState]

property dt: float

Calculation duration.

Returns:

duration, seconds.

Return type:

float

property id: int

The result’s ID.

Returns:

result id

Return type:

int

property labels: Dict[str, str]

Labels that annotate and classify the calculation result.

Returns:

Labels

Return type:

Dict[str,str]

property phs: Dict[str, PhaseState]

The equilibrium phase states.

Returns:

phase states

Return type:

Dict[str, PhaseState]

property scs: Dict[str, SystemComponentState]

The equilibrium system component states.

Returns:

system component states

Return type:

Dict[str, PhaseState]

property t_end: float

Calculation end time.

Returns:

end time

Return type:

float

property t_start: float

Calculation start time.

Returns:

start time

Return type:

float

property ts_md5: str

The md5 checksum of the thermochemical data file that the result is based on.

Returns:

md5 hash

Return type:

float

property units: Dict[str, PressureUnit | VolumeUnit | TemperatureUnit | EnergyUnit | AmountUnit]

The units used for the calculation.

Returns:

units

Return type:

Dict[str, PressureUnit | VolumeUnit | TemperatureUnit | EnergyUnit | AmountUnit]

create_gas_stream(name, include_zeros=False)

Create a stream state object from this result object including only phases that are gasses.

Parameters:
  • name (str) – stream name

  • include_zeros (bool) – include zero values (default: False)

Returns:

new stream object

Return type:

StreamState

create_liquid_stream(name, include_zeros=False)

Create a stream state object from this result object including only phases that are liquid.

Parameters:
  • name (str) – stream name

  • include_zeros (bool) – include zero values (default: False)

Returns:

new stream object

Return type:

StreamState

create_solid_stream(name, include_zeros=False)

Create a stream state object from this result object including only phases that are solid.

Parameters:
  • name (str) – stream name

  • include_zeros (bool) – include zero values (default: False)

Returns:

new stream object

Return type:

StreamState

create_stream(name, include_zeros=False, phs_include=None, phs_exclude=None, els_include=None, els_exclude=None, phsconfigs=None, el_threshold=0.0)

Create a stream state object from this result object.

Either phs_include _or_ phs_exclude can be defined. Equally, only either els_include _or_ els_exclude can be used. If the latter is employed, the parameter phsconfig needs to be given, too. It can be acquired through ThermochemicalSystem.get_config_phs().

Parameters:
  • name (str) – stream name

  • include_zeros (bool) – include zero values

  • phs_include (List[str]) – phases to include

  • phs_exclude (List[str]) – phases to ignore

  • els_include (List[str]) – elements to include

  • els_exclude (List[str]) – elements to ignore

  • phsconfigs (ThermochemicalSystemConfig) – phase configurations, as returned by ThermochemicalSystem.get_config_phs()

  • el_threshold (float) – minimum threshold value to be considered (default: 0.0)

Returns:

new stream object

Return type:

StreamState

create_stream_by_state(state, name, include_zeros=False)

Create a stream state object from this result object including only phases that match the ‘state’.

Parameters:
  • state (PhaseMatterState) – phase state

  • name (str) – stream name

  • include_zeros (bool) – include zero values (default: False)

Returns:

new stream object

Return type:

StreamState

get_eq_phs(A=0.0)

Get the list of stable phases from this result object.

The criteria for stability is phase activity to be equal to 1, and the amount being larger than the given threshold A

Parameters:

A (float) – minimum threshold for a stable phase amount (default: 0.0)

Returns:

list of references to phase state objects

Return type:

List[PhaseState]

class chemapp.friendly.InteractionVariable

Bases: enum.Enum

Enum to specific the type of interaction parameter to extract.

Option

Meaning

G

Gibbs energy function excess parameters

M

Magnetic interaction parameters

class chemapp.friendly.IoOption

Bases: enum.Enum

Input/output options used by tqgio() and tqcio().

Option

Meaning

Default value

FILE

Unit from which the thermodynamic data-file is read

10

ERROR

Unit to which error messages are directed

6

LIST

Unit to which optional equilibrium output lists are directed

6

LANGUAGE

Language used for error messages (1=English, 2=German, 3=French, 4=Swedish, 5=Finnish)

1

class chemapp.friendly.PhaseConfig

Bases: ObjectDescriptor

This class represents the configuration of a phase as read from a thermochemical data file.

Parameters:
  • index (int) – phase one-based index

  • name (str) – phase name

  • model (SolutionModel) – phase’s solution model

  • pcs (List[PhaseConstituentConfig]) – phase constituent configuration objects

  • alt_name (str) – phase’s alternative name

property alt_name: str

The phase’s alternative name.

Returns:

name

Return type:

str

property model: SolutionModel

The phase’s solution model.

Returns:

phase model

Return type:

SolutionModel

property pcs: Dict[str, PhaseConstituentState]

The equilibrium phase constituent states.

Returns:

phase constituent states

Return type:

Dict[str, PhaseConstituentState]

class chemapp.friendly.PhaseConstituentConfig

Bases: ObjectDescriptor

This class represents the configuration of a phase constituent as read from a file.

Parameters:
  • index (int) – phase constituent one-based index

  • name (str) – phase constituent name

  • mm (float) – phase constituent molar mass

  • stoich (Dict[str,float]) – phase constituent stoichiometry

  • y_scs (Dict[str,float]) – system component mass fractions

property mm: float

The phase constituent’s molar mass.

Returns:

molar mass

Return type:

float

property stoich: Dict[str, float]

The phase constituent’s stoichiometry.

Returns:

stoichiometry

Return type:

Dict[str,float]

property y_scs: Dict[str, float]

The mass fraction of system components in the constituent.

Returns:

mass fractions

Return type:

Dict[str,float]

class chemapp.friendly.PhaseConstituentData

Bases: enum.Enum

Available data items that can be requested for phase constituents.

OPTION

Variable

H

Enthalpy/J at 298.15K

S

Entropy/J*K-1 at 298.15K

Cp

Heat capacity expression/J.K-1 or Helgeson terms for the models PIHZ, HELZ, HTSZ, HTWZ or HTDZ

V

Molar volume data in input order of a condensed phase constituent

Gc

Critical properties in input order of a gas phase constituent

Ht

Transformation enthalpy/J at the upper temperature limit for a Cp range

M

Curie/Neel temperature and average magnetic moment per atom for a magnetic phase constituent

Tt

Upper temperature limit/K for a Cp range

Ch

Charge of an aqueous phase constituent

class chemapp.friendly.PhaseConstituentIncomingAmountState

Bases: IncomingAmountState

This class represents the state of an phase constituent incoming amount in an equilibrium calculation result.

Parameters:
  • ph (str) – phase name

  • pc (str) – phase constituent name

  • A (float) – amount value

property pc: str

Phase constituent name.

Returns:

constituent name

Return type:

str

property ph: str

Phase name.

Returns:

phase name

Return type:

str

class chemapp.friendly.PhaseConstituentState

Bases: ObjectDescriptor

This class represents the state of a phase constituent in an equilibrium calculation result.

Parameters:
  • index (int) – phase constituent one-based index

  • name (str) – phase constituent name

  • status (Status) – phase constituent status

property status: Status

The phase constituent’s status.

Returns:

phase constituent status

Return type:

Status

class chemapp.friendly.PhaseConstituentVariable

Bases: enum.Enum

Available variables for extracting thermodynamic properties of phase constituents.

Value

Description

CP

Heat capacity

G

Gibbs energy

H

Enthalpy

S

Entropy

T

Temperature (used to retrieve the upper limit of the current temperature interval for a given phase constituent or a stoichiometric condensed phase)

V

Volume

class chemapp.friendly.PhaseMapVariable

Bases: enum.Enum

Variables that can be used to adjust conditions as part of phase map calculations.

Option

Variable

Comment

PF / PN

Total pressure

Pressure is the search variable. The upper and lower bounds of the pressure search interval are in VALS(1) and VALS(2). Use option ‘PF’ for the first call to tqmap(), and ‘PN’ for all subsequent ones.

TF / TN

Temperature

Temperature is the search variable. The upper and lower bounds of the temperature search interval are in VALS(1) and VALS(2). Use option ‘TF’ for the first call to tqmap(), and ‘TN’ for all subsequent ones.

IA0 / IAF / IAN

Incoming amount

Incoming amount is the search variable. The upper and lower bounds of the composition search interval are in VALS(1) and VALS(2). If incoming amounts for more than one substance need to be defined, all except the last one have to be called using ‘IA0’ as option to tqmap(). Once ‘IAF’ is passed for the last incoming amount, the first calculation is made. Use option ‘IAN’ for all subsequent ones.

class chemapp.friendly.PhaseState

Bases: ObjectDescriptor

This class represents the state of a phase in an equilibrium calculation result.

Parameters:
  • index (int) – phase one-based index

  • name (str) – phase name

  • status (Status) – phase status

property pcs: Dict[PhaseConstituentState]

The equilibrium phase constituent states.

Returns:

phase constituent states

Return type:

Dict[PhaseConstituentState]

property scs: Dict[SystemComponentState]

The equilibrium system component states.

Returns:

system component states

Return type:

Dict[SystemComponentState]

property status: Status

The phase’s status.

Returns:

phase status

Return type:

Status

class chemapp.friendly.PressureUnit

Bases: enum.Enum

Available pressure units.

Option

bar

atm

Pa

kPa

psi

torr

class chemapp.friendly.Quantity

Bases: enum.Enum

Quantities available for setting units.

Quantity

Unit

Pressure

bar

atm

Pa

kPa

psi

torr

Volume

dm3

cm3

m3

ft3

in3

Temperature

K

C

F

Energy

J

cal

Btu

kWh

Amount

mol

gram

kg

tonne

pound

class chemapp.friendly.ResultVariable

Bases: enum.Enum

Result variables available after equilibrium calculations.

Option

Variable

Comment

P

Total pressure

VT

Total volume

T

Temperature

A

Equilibrium amount

IA

Incoming amount

Not valid for phases or for the entire system

MU, AC

Chemical potential, Activity/fugacity

Relative values for phases and constituents; absolute values for system components; fugacities in current pressure unit for gas phase constituents.

pH, Eh

pH, Eh/V

The calculation of pH and Eh/V requires that the constituents H+ in the aqueous phase and H2 in the gas phase be present in the thermochemical data-file. If pH and Eh/V cannot be calculated, theoutput VAL=0.0 will be returned. In order for ChemApp to recognize H+ and H2 in the data-file, the names of the system components hydrogen and aqueous electron must be ‘H’ and ‘EA’, respectively (see TQCNSC).

CP, H, S, G, V,

Heat capacity, Enthalpy, Entropy, Gibbs energy, Volume

Not valid for system components. Extensive properties for the equilibrium state dependent on the inherent reference state of the data. However, when the entire system is selected and streams are used, the values represent balances, i.e. the extensive property for the equilibrium state minus the sum of values for all streams. To obtain the total volume in this case, use option ‘VT’.

CPM, HM, SM, GM, VM

Heat capacity/ amount unit, Enthalpy/ amount unit, Entropy/ amount unit, Gibbs energy/ amount unit, Volume/ amount unit

Not valid for system components. Partial values are returned for constituents, integral values for phases. Values are valid for default or selected amount units.

X

Fraction

Mass or mole fraction of a system component in the system, depending on the default or selected amount unit.

XP

Fraction

Mass or mole fraction of a system component in a phase, depending on the default or selected amount unit.

AP

Equilibrium amount

Equilibrium amount of (a) system component(s) in a phase.

class chemapp.friendly.SolutionModel

Bases: enum.Enum

Available solution models.

Model

Description

BDEF

Binary defect formalism

GAYE

Gaye-Kapoor-Frohberg cell formalism with or without non-oxidic solutes

HOCH

Hoch-Arpshofen formalism

HOCHM

Hoch-Arpshofen formalism with magnetism

IDBS

Gaseous model - C-H-O-S-N-Ar superfluid formalism

IDMX

Ideal mixing

IDVT

Gaseous model - Virial equation with Tsonopoulos second virial coefficient correlation

PURE

Stoichiometric condensed phase

QKTO

General polynomial Kohler/Toop formalism

QKTOM

General polynomial Kohler/Toop formalism with magnetism

QSOL

Modified quasichemical formalism with nonoxidic solutes

QUAS

Modified quasichemical formalism

QUSL

Two-sublattice equivalent fraction formalism as a polynomial

QUSLM

Two-sublattice equivalent fraction formalism as a polynomial with magnetism

RKMP

Redlich-Kister-Muggianu polynomial

RKMPM

Redlich-Kister-Muggianu polynomial with magnetism

SUBE

Extended compound energy formalism

SUBEM

Extended compound energy formalism with magnetism

SUBG

Quadruplet quasichemical model

SUBGM

Quadruplet quasichemical model with magnetism

SUBI

Two-sublattice ionic formalism

SUBL

Compound energy formalism

SUBLM

Compound energy formalism with magnetism

SUBM

Two-sublattice equivalent fraction formalism

SUBMM

Two-sublattice equivalent fraction formalism with magnetism

SUBO

Two-sublattice order/disorder formalism

SUBOM

Two-sublattice order/disorder formalism with magnetism

SUBQ

Quadruplet quasichemical model with composition-dependent coordination numbers

SUBQM

Quadruplet quasichemical model with composition-dependent coordination numbers with magnetism

SUBS

Species chemical potential/bond energy formalism

WAGN

Unified interaction parameter formalism

WAGNM

Unified interaction parameter formalism with magnetism

HELZ

Aqueous model - Revised Helgeson-Kirkham-Flowers formalism

HTDZ

Aqueous model - Helgeson-Tanger-Shock formalism (Davies)

HTSZ

Aqueous model - Helgeson-Tanger-Shock formalism (ideal)

HTWZ

Aqueous model - Helgeson-Tanger-Shock formalism (Debye-Hueckel)

IDDZ

Aqueous model - Davies formalism

IDWZ

Aqueous model - Ideal aqueous mixing

PIHZ

Aqueous model - Helgeson-Tanger-Shock formalism (Pitzer)

PIMZ

Aqueous model - Pitzer formalism

PITZ

Aqueous model - Pitzer formalism with fixed alpha-1 and alpha-2

PIWZ

Aqueous model - Pitzer formalism without E-theta and E-theta’

SITZ

Aqueous model - Specific ion-interaction formalism

class chemapp.friendly.Status

Bases: enum.Enum

Status values for phases and phase constituents.

Status

Description

ENTERED

The phase or constituent is included in the equilibrium calculation. An included phase is not necessarily stable at equilibrium.

DORMANT

The phase or constituent is excluded from the mass balances (it will appear with zero amount at equilibrium), but its activity is calculated. If the calculated activity for a phase is greater than one, it would be stable if entered.

ELIMINATED

The phase or constituent is ignored in the equilibrium calculation

class chemapp.friendly.StreamCalculationResult

Bases: EquilibriumCalculationResult

See EquilibriumCalculationResult

streams()

Get the streams that are input to the equilibrium calculation.

Returns:

Streams that were input to the equilibrium calculation.

Return type:

Dict[StreamState]

class chemapp.friendly.StreamState

Bases: ConvertableObject

This class represents the state of a stream used as input to a stream equilibrium calculation (StreamCalculation).

Parameters:
  • name (str) – stream name

  • T (float) – stream temperature

  • P (float) – stream pressure

property A: float

Total stream amount.

Returns:

stream amount

Return type:

float

property A_pcs: List[PhaseConstituentIncomingAmountState]

Phase constituent amounts.

Returns:

phase constituent amounts

Return type:

List[PhaseConstituentIncomingAmountState]

property name: str

Stream name.

Returns:

name

Return type:

str

property units: Dict[str, PressureUnit | VolumeUnit | TemperatureUnit | EnergyUnit | AmountUnit]

The units used for the stream.

Returns:

units used

Return type:

Dict[str, PressureUnit | VolumeUnit | TemperatureUnit | EnergyUnit | AmountUnit]

combine_with(other, name='')

Add another stream’s phase constituent to this stream and return the result.

The StreamState object for which this function is called remains unchanged.

The returned Cp, H, S, G, V property is set to ‘nan’.

Parameters:
  • other (StreamState) – The other StreamState object to combine.

  • name (str) – A name for the returned new StreamState object. If empty, keep ‘self’ name.

Returns:

copy of this stream including the incoming phase amounts from ‘other’

Return type:

StreamState

remove_above_threshold(threshold=0.001, inplace=False)

Remove all phase constituents with amounts above the given threshold.

Parameters:
  • threshold (float) – the threshold for removal (default=0.001)

  • inplace (bool) – whether a copy should be returned or the object itself is modified (default=False)

Returns:

object with the phase constituents below the given threshold

Return type:

StreamState

remove_below_threshold(threshold=0.001, inplace=False)

Remove all phase constituents with amounts below the given threshold.

Parameters:
  • threshold (float) – the threshold for removal (default=0.001)

  • inplace (bool) – whether a copy should be returned or the object itself is modified (default=False)

Returns:

object with the phase constituents above the given threshold.

Return type:

StreamState

split_at_threshold(threshold=0.001)

Split a stream into two streams.

The two streams will be named <name>_lower and <name>_higher, with respect to phase constituent amounts and given threshold.

Parameters:

threshold (float) – value at which to split (default=0.001)

Returns:

tuple of StreamState. All phase constituents with amounts below threshold are in the first item.

Return type:

Tuple[StreamState, StreamState]

split_by_states()

Split a stream into three streams named <name>_liquid, <name>_solid, <name>_gas by their respective state of matter.

Returns:

(solids, liquids, gaseous) tuple of StreamState with the respective matter of state.

Return type:

Tuple[StreamState, StreamState, StreamState]

class chemapp.friendly.StreamVariable(*args, **kwds)

Bases: enum.Enum

Available variables for stream properties that can be extracted.

Option

Variable

Unit

CP

Heat capacity

[current energy unit]/K

H

Enthalpy

[current energy unit]

S

Entropy

[current energy unit]/K

G

Gibbs energy

[current energy unit]

V

Volume

[current volume unit]

class chemapp.friendly.SystemComponentConfig

Bases: ObjectDescriptor

This class represents the configuration of a system component as read from a file.

Parameters:
  • index (int) – system component one-based index

  • name (str) – system component name

  • mm (float) – system component molar mass

property mm: float

The system component’s molar mass.

Returns:

molar mass

Return type:

float

class chemapp.friendly.SystemComponentIncomingAmountState

Bases: IncomingAmountState

This class represents the state of a system component incoming amount in an equilibrium calculation result.

Parameters:
  • sc (str) – system component name

  • A (float) – amount value

property sc: str

System component name.

Returns:

name

Return type:

str

class chemapp.friendly.SystemComponentState

Bases: ObjectDescriptor

This class represents the state of a system component in an equilibrium calculation result.

Parameters:
  • index (int) – phase one-based index

  • name (str) – phase name

class chemapp.friendly.TargetVariable

Bases: enum.Enum

Variables that can be used in target calculations to arrive at a specified target condition.

Option

Variable

Description

P

Total pressure

Pressure is a target variable. The value VALS(1) serves as an initial estimate, VALS(2) is not used.

V

Total volume

Volume is a target variable. The value VALS(1) serves as an

initial estimate, VALS(2) is not used.

T

Temperature

Temperature is a target variable. The value VALS(1) serves as an initial estimate, VALS(2) is not used.

IA, IA0, MU

Incoming amount, Chemical potential

Incoming amount is a target variable. The values VALS(1) and VALS(2) denote lower and upper limits, respectively. When defining streams, the constituent is included in the last stream considered. If incoming amounts for more then one substance need to be defined, all except the last one have to be called using ‘IA0’ as option to TQCE/TQCEL. Once ‘IA’ is passed for the last incoming amount, the first calculation is made.

Blank

Calculate without any target variable, VALS is not used.

class chemapp.friendly.TemperatureUnit

Bases: enum.Enum

Available temperature units.

Temperature

K

C

F

class chemapp.friendly.ThermochemicalSystemConfig

Bases: ConvertableObject

An object of this class stores all the information about a thermochemical system as it is read from a thermochemical data file.

Parameters:
property file_content: str

The binary content of the thermochemical data file from which the thermochemical system was loaded.

Return type:

str

property file_expiry_date: float

The expiry date of the thermochemical data file from which the thermochemical system was loaded.

Return type:

float

property file_md5: str

The MD5 hash of the thermochemical data file from which the thermochemical system was loaded.

Return type:

str

property file_name: str

The name of the thermochemical data file from which the thermochemical system was loaded.

Return type:

str

property file_path: str

The path of the thermochemical data file from which the thermochemical system was loaded.

Return type:

str

property phs: Dict[str, PhaseConfig]

Dictionary of phases.

Return type:

Dict[str, PhaseConfig]

property scs: Dict[str, SystemComponentConfig]

Dictionary of system components.

Return type:

Dict[str, SystemComponentConfig]

property units: Dict[str, PressureUnit | VolumeUnit | TemperatureUnit | EnergyUnit | AmountUnit]

The ChemApp units that were active when this object was created.

All numbers stored in this object and its child objects are in these units.

Return type:

Dict[str, PressureUnit | VolumeUnit | TemperatureUnit | EnergyUnit | AmountUnit]

class chemapp.friendly.VolumeUnit

Bases: enum.Enum

Available volume units.

Volume

dm3

cm3

m3

ft3

in3

chemapp.friendly.switch_components(composition, components, tol=1e-05, normalize=False)

Determine the stoichiometric factors for a composition given a set of arbitrary components.

This function returns the numeric factors needed to create composition from the list of chemical formulae given in components.

Parameters:
  • composition (str) – chemical formulae of the composition to be decomposed

  • components (List[str]) – components which are linearly combined to form composition

  • tol (float) – tolerance value for matching exact stoichiometries (default=1e-5)

  • normalize (bool) – scale the sum of stoichiometric factors to 1 (default=false)

Return type:

List[float]

Examples

>>> switch_components("Fe3O4", ["FeO", "O2"])
[3.0, 2.0]
>>> switch_components("SrNaCl3", ["NaCl", "SrCl2"])
[1.0, 1.0]
>>> switch_components("SrNaCl3", ["NaCl", "Sr", "Cl"])
[1.0, 1.0, 2.0]

Notice that the method uses a least square method internally to find a solution. Therefore, it is not necessary for the components to be orthogonal to each other, e.g. one component can be a linear combination of others.

>>> switch_components("SrNaCl3", ["NaCl", "Cl2","Sr", "Cl"])
[1.0, 0.8, 1.0, 0.4]

However, in that case the solution is obviously not unique. Using the “normalize” option will not change that.

>>> switch_components("Fe3O4", ["FeO", "O2"], normalize=True)
[0.8571.., 0.1428..]

Using the tol option allows to approximate factors, e.g. in case of non-integer component compositions:

>>> switch_components("Al2O5", ["Al1.125O", "O"], tol=1e-2)
[1.78, 3.22]
Returns:

The stoichiometric factors for components that will form composition

Return type:

List[float]

Raises:

ValueError – In case there does not exist a rational positive solution given the inputs.

Parameters:
  • composition (str) –

  • components (List[str]) –

  • tol (float) –

  • normalize (bool) –

class chemapp.friendly.AbsoluteEquilibriumCalculationBase

Bases: EquilibriumCalculationBase

This abstract class provides base functionality for absolute equilibrium calculations, such as EquilibriumCalculation and PhaseMapCalculation.

StreamCalculation is classified as relative, since its streams provide initial conditions relative to which extensive variable changes can be calculated.

classmethod get_result_object(result_type=chemapp.core.EquilibriumCalculationResult, error=False)

Extract an equilibrium calculation’s results in the form of a chemapp.core.EquilibriumCalculationResult object.

Returns:

An object that holds all numeric results of a calculation

Return type:

EquilibriumCalculationResult | StreamCalculationResult

Parameters:

error (bool) –

classmethod set_IA_cfs(cfs, values)

Set chemical formula incoming amounts.

The chemical formulas input can be in formats such as NaOH3, Fe2O3, Cr0.3Mn0.7C, or Na(OH)2, which are all accepted as long as the composition can be expressed using the system components. Special care needs to be taken given that the resulting amounts of the system components will be depending on the units used and the correct input of molar masses.

Parameters:
  • cfs (List[str]) – list of chemical formulae

  • value – incoming amount values

  • values (List[float]) –

Returns:

equilibrium condition numbers, one for each system component

Return type:

List[int]

classmethod set_IA_pc(ph, pc, value)

Set the incoming amount of a phase constituent.

Parameters:
  • ph (str | int) – The name or zero-based index of the phase.

  • pc (str | int) – The name or zero-based index of the phase constituent.

  • value (float) – The incoming amount value.

Returns:

The equilibrium condition number.

Return type:

int

classmethod set_IA_sc(sc, value)

Set the system component’s incoming amount.

Parameters:
  • sc (str | int) – system component name or zero-based index

  • value (float) – incoming amount value

Returns:

equilibrium condition number

Return type:

int

classmethod set_eq_AC_pc(ph, pc, value)

Set the phase constituent’s equilibrium activity.

Parameters:
  • ph (str | int) – phase name or zero-based index

  • pc (str | int) – constituent name or zero-based index

  • value (float) – activity value

Returns:

Equilibrium condition number

Return type:

int

classmethod set_eq_AC_sc(sc, value)

Set the system component’s equilibrium activity.

Parameters:
  • sc (str | int) – system component name or zero-based index

  • value (float) – equilibrium activity value

Returns:

Equilibrium condition number

Return type:

int

classmethod set_eq_MU_pc(ph, pc, value)

Set the phase constituent’s equilibrium chemical potential.

Parameters:
  • ph (str | int) – phase name or zero-based index

  • pc (str | int) – phase constituent name or zero-based index

  • value (float) – chemical potential value

Returns:

Equilibrium condition number

Return type:

int

class chemapp.friendly.EquilibriumCalculation

Bases: AbsoluteEquilibriumCalculationBase

This class provides facilities to perform normal (non-stream, non-phase map) equilibrium calculations.

classmethod calculate_eq(print_results=False, estimate=False, return_result=False, **kwargs)

Calculate the equilibrium.

Any keyword arguments for get_result_object can be added and will be passed to the result object if return_result is true.

Parameters:
  • print_results (bool) – Indicates whether the results should be printed to console or not.

  • estimate (bool) – Indicates whether to use the previous calculation’s results as an initial estimate.

  • return_result (bool) – Indicates whether the routine immediately returns a ResultObject.

  • **kwargs – arbitrary keyword argument list, handed through to the result object creation.

Returns:

if return_result is set to True

Return type:

EquilibriumCalculationResult

classmethod calculate_eq_IA(IA_ranges, print_results=False)

Search for the target by adjusting the specified incoming amounts.

Parameters:
  • IA_ranges (List[Tuple[str, str, float, float]]) – List of incoming amount ranges. Each tuple should be (ph:str, pc:str, IA_min:float, IA_max:float)

  • print_results – Indicates whether the results should be printed to console or not (default is False)

Returns:

incoming amounts. tuple list [(ph, pc, IA), …]

Return type:

List[Tuple[str, str, float]]

classmethod calculate_eq_P(P_guess, print_results=False)

Search for the target by adjusting pressure, and use the provided guess as a starting value.

Parameters:
  • P_guess (float) – pressure guess value to start search

  • print_results (bool) – indicates whether the results should be printed to console or not

Returns:

resulting pressure

Return type:

float

classmethod calculate_eq_T(T_guess, print_results=False)

Search for the target by adjusting temperature, and use the provided guess as a starting value.

Parameters:
  • T_guess (float) – temperature guess value to start search

  • print_results (bool) – indicates whether the results should be printed to console or not

Returns:

resulting temperature

Return type:

float

classmethod calculate_eq_V(V_guess, print_results=False)

Search for the target by adjusting volume, and use the provided guess as a starting value.

Parameters:
  • V_guess (float) – volume guess value to start search

  • print_results (bool) – indicates whether the results should be printed to console or not

Returns:

resulting volume

Return type:

float

classmethod set_target_AC_pc(ph, pc, value)

Set the target as the activity of the specified phase constituent.

Parameters:
  • ph (str | int) – phase name or index

  • pc (str | int) – phase constituent name or index

  • value (float) – activity value

classmethod set_target_XT_pc(ph, pc, value)

Set the target as the mole fraction of the specified phase constituent.

Parameters:
  • ph (str | int) – phase name or index

  • pc (str | int) – phase consituent name or index

  • value (float) – mole fraction value

classmethod set_target_XT_sc_in_ph(sc, ph, value)

Set the target as the mole fraction of the specified system component in the specified phase.

Parameters:
  • sc (str | int) – system component name or index

  • ph (str | int) – phase name or index

  • value (float) – mole fraction value

classmethod set_target_formation_of_ph(ph)

Set the target as formation of the specified phase.

Parameters:

ph (str | int) – phase name or index

classmethod set_target_precipitation_from_ph(ph)

Set the target as precipitation from the specified phase.

Parameters:

ph (str | int) – phase name or index

classmethod set_tg_AC_pc(ph, pc, value)

Set the target as the activity of the specified phase constituent.

FutureWarning: This function is renamed to set_target_AC_pc. set_tg_AC_pc will be removed in a future version.

Deprecated since version 826: This function is renamed to set_target_AC_pc. set_tg_AC_pc will be removed in a future version.

Parameters:
  • ph (str | int) – phase name or index

  • pc (str | int) – phase constituent name or index

  • value (float) – activity value

classmethod set_tg_XT_pc(ph, pc, value)

Set the target as the mole fraction of the specified phase constituent.

FutureWarning: This function is renamed to set_target_XT_pc. set_tg_XT_pc will be removed in a future version.

Deprecated since version 826: This function is renamed to set_target_XT_pc. set_tg_XT_pc will be removed in a future version.

Parameters:
  • ph (str | int) – phase name or index

  • pc (str | int) – phase consituent name or index

  • value (float) – mole fraction value

classmethod set_tg_XT_sc_in_ph(sc, ph, value)

Set the target as the mole fraction of the specified system component in the specified phase.

FutureWarning: This function is renamed to set_target_XT_sc_in_ph. set_tg_XT_sc_in_ph will be removed in a future version.

Deprecated since version 826: This function is renamed to set_target_XT_sc_in_ph. set_tg_XT_sc_in_ph will be removed in a future version.

Parameters:
  • sc (str | int) – system component name or index

  • ph (str | int) – phase name or index

  • value (float) – mole fraction value

classmethod set_tg_formation_of_ph(ph)

Set the target as formation of the specified phase.

FutureWarning: This function is renamed to set_target_formation_of_ph. set_tg_formation_of_ph will be removed in a future version.

Deprecated since version 826: This function is renamed to set_target_formation_of_ph. set_tg_formation_of_ph will be removed in a future version.

Parameters:

ph (str | int) – phase name or index

classmethod set_tg_precipitation_from_ph(ph)

Set the target as precipitation from the specified phase.

FutureWarning: This function is renamed to set_target_precipitation_from_ph. set_tg_precipitation_from_ph will be removed in a future version.

Deprecated since version 826: This function is renamed to set_target_precipitation_from_ph. set_tg_precipitation_from_ph will be removed in a future version.

Parameters:

ph (str | int) – phase name or index

class chemapp.friendly.EquilibriumCalculationBase

This class provides base functionality share between all equilibrium calculation classes.

classmethod get_eq_A()

Get the system’s total amount at equilibrium.

Returns:

amount value

Return type:

float

classmethod get_eq_AC_pc(ph, pc)

Get the phase constituent’s activity at equilibrium.

Parameters:
  • ph (str | int) – phase name or zero-based index

  • pc (str | int) – phase constituent name or zero-based index

Returns:

activity value

Return type:

float

classmethod get_eq_AC_pcs()

Get the activity at equilibrium for all phase constituents.

All phase constituents of all phases as a continuous list.

Returns:

activity values

Return type:

List[float]

classmethod get_eq_AC_pcs_in_ph(ph)

Get the activity at equilibrium for all phase constituents in the specified phase.

Parameters:

ph (str | int) – phase name or zero-based index

Returns:

activity values

Return type:

List[float]

classmethod get_eq_AC_ph(ph)

Get the phase’s activity at equilibrium.

Parameters:

ph (str | int) – phase name or zero-based index

Returns:

activity value

Return type:

float

classmethod get_eq_AC_phs()

Get the activity at equilibrium for all phases.

Returns:

activity values

Return type:

List[float]

classmethod get_eq_AC_sc(sc)

Get the system component’s activity at equilibrium.

Parameters:

sc (str | int) – system component name or zero-based index

Returns:

activity value

Return type:

float

classmethod get_eq_AC_scs()

Get the activity at equilibrium for all system components.

Returns:

activity values

Return type:

List[float]

classmethod get_eq_A_pc(ph, pc)

Get the phase constituent’s amount at equilibrium.

Parameters:
  • ph (str | int) – phase name or zero-based index

  • pc (str | int) – phase constituent name or zero-based index

Returns:

amount value

Return type:

float

classmethod get_eq_A_pcs()

Get the amount at equilibrium for all phase constituents.

Returns:

amount values

Return type:

List[float]

classmethod get_eq_A_pcs_in_ph(ph)

Get the amount at equilibrium for all phase constituents in the specified phase.

Parameters:

ph (str | int) – phase name or zero-based index

Returns:

amount values

Return type:

List[float]

classmethod get_eq_A_ph(ph)

Get the phase’s amount at equilibrium.

Parameters:

ph (str | int) – phase name or zero-based index

Returns:

amount value

Return type:

float

classmethod get_eq_A_phs()

Get the amount at equilibrium for all phases.

Returns:

amount values

Return type:

List[float]

classmethod get_eq_A_sc(sc)

Get the system component’s amount at equilibrium.

Parameters:

sc (str | int) – system component name or zero-based index

Returns:

amount value

Return type:

float

classmethod get_eq_A_sc_in_ph(ph, sc)

Get the equilibrium amount of the specified system component in the specified phase.

Parameters:
  • sc (str | int) – system component name or index

  • ph (str | int) – phase name or index

Returns:

amount value

Return type:

float

classmethod get_eq_A_scs()

Get the amount at equilibrium for all system components.

Returns:

list of amount values

Return type:

List[float]

classmethod get_eq_A_scs_in_ph(ph)

Get the equilibrium amount of all system components in the specified phase.

Parameters:
  • sc – system component name or index

  • ph (str | int) – phase name or index

Returns:

amount values

Return type:

List[float]

classmethod get_eq_Cp()

Get the system’s heat capacity at equilibrium.

Returns:

heat capacity value

Return type:

float

classmethod get_eq_CpM()

Get the system’s heat capacity per amount at equilibrium.

Returns:

heat capacity per amount value

Return type:

float

classmethod get_eq_CpM_pc(ph, pc)

Get the phase constituent’s heat capacity per amount at equilibrium.

Parameters:
  • ph (str | int) – phase name or zero-based index

  • pc (str | int) – phase constituent name or zero-based index

Returns:

heat capacity per amount value

Return type:

float

classmethod get_eq_CpM_pcs()

Get the heat capacity per amount at equilibrium for all phase constituents.

Returns:

heat capacity per amount values

Return type:

List[float]

classmethod get_eq_CpM_pcs_in_ph(ph)

Get the heat capacity per amount at equilibrium for all phase constituents in the specified phase.

Parameters:

ph (str | int) – phase name or zero-based index

Returns:

heat capacity per amount values

Return type:

List[float]

classmethod get_eq_CpM_ph(ph)

Get the phase’s heat capacity per amount at equilibrium.

Parameters:

ph (str | int) – phase name or zero-based index

Returns:

heat capacity per amount value

Return type:

float

classmethod get_eq_CpM_phs()

Get the heat capacity per amount at equilibrium for all phases.

Returns:

heat capacity per amount values

Return type:

List[float]

classmethod get_eq_Cp_pc(ph, pc)

Get the phase constituent’s heat capacity at equilibrium.

Parameters:
  • ph (str | int) – phase name or zero-based index

  • pc (str | int) – phase constituent name or zero-based index

Returns:

heat capacity value

Return type:

float

classmethod get_eq_Cp_pcs()

Get the heat capacity at equilibrium for all phase constituents.

Returns:

heat capacity values

Return type:

List[float]

classmethod get_eq_Cp_pcs_in_ph(ph)

Get the heat capacity at equilibrium for all phase constituents in the specified phase.

Parameters:

ph (str | int) – phase name or zero-based index

Returns:

heat capacity values

Return type:

List[float]

classmethod get_eq_Cp_ph(ph)

Get the phase’s heat capacity at equilibrium.

Parameters:

ph (str | int) – phase name or zero-based index

Returns:

heat capacity value

Return type:

float

classmethod get_eq_Cp_phs()

Get the heat capacity at equilibrium for all phases.

Returns:

heat capacity values

Return type:

List[float]

classmethod get_eq_G()

Get the system’s Gibbs energy at equilibrium.

Returns:

Gibbs energy value

Return type:

float

classmethod get_eq_GM()

Get the system’s Gibbs energy per amount at equilibrium.

Returns:

Gibbs energy per amount value

Return type:

float

classmethod get_eq_GM_pc(ph, pc)

Get the phase constituent’s Gibbs energy per amount at equilibrium.

Parameters:
  • ph (str | int) – phase name or zero-based index

  • pc (str | int) – phase constituent name or zero-based index

Returns:

Gibbs energy per amount value

Return type:

float

classmethod get_eq_GM_pcs()

Get the Gibbs energy per amount at equilibrium for all phase constituents.

Returns:

Gibbs energy per amount value

Return type:

List[float]

classmethod get_eq_GM_pcs_in_ph(ph)

Get the Gibbs energy per amount at equilibrium for all phase constituents in the specified phase.

Parameters:

ph (str | int) – phase name or zero-based index

Returns:

Gibbs energy per amount value

Return type:

List[float]

classmethod get_eq_GM_ph(ph)

Get the phase’s Gibbs energy per amount at equilibrium.

Parameters:

ph (str | int) – phase name or zero-based index

Returns:

Gibbs energy per amount value

Return type:

float

classmethod get_eq_GM_phs()

Get the Gibbs energy per amount at equilibrium for all phases.

Returns:

Gibbs energy per amount value

Return type:

List[float]

classmethod get_eq_G_pc(ph, pc)

Get the phase constituent’s Gibbs energy at equilibrium.

Parameters:
  • ph (str | int) – phase name or zero-based index

  • pc (str | int) – phase constituent name or zero-based index

Returns:

Gibbs energy value

Return type:

float

classmethod get_eq_G_pcs()

Get the Gibbs energy at equilibrium for all phase constituents.

Returns:

Gibbs energy value

Return type:

float

classmethod get_eq_G_pcs_in_ph(ph)

Get the Gibbs energy at equilibrium for all phase constituents in the specified phase.

Parameters:

ph (str | int) – phase name or zero-based index

Returns:

Gibbs energy value

Return type:

float

classmethod get_eq_G_ph(ph)

Get the phase’s Gibbs energy at equilibrium.

Parameters:

ph (str | int) – phase name or zero-based index

Returns:

Gibbs energy value

Return type:

float

classmethod get_eq_G_phs()

Get the Gibbs energy at equilibrium for all phases.

Returns:

Gibbs energy value

Return type:

float

classmethod get_eq_H()

Get the system’s enthalpy at equilibrium.

Returns:

enthalpy value

Return type:

float

classmethod get_eq_HM()

Get the system’s enthalpy per amount at equilibrium.

Returns:

enthalpy per amount value

Return type:

float

classmethod get_eq_HM_pc(ph, pc)

Get the phase constituent’s enthalpy per amount at equilibrium.

Parameters:
  • ph (str | int) – phase name or zero-based index

  • pc (str | int) – phase constituent name or zero-based index

Returns:

enthalpy per amount value

Return type:

float

classmethod get_eq_HM_pcs()

Get the enthalpy per amount at equilibrium for all phase constituents.

Returns:

enthalpy per amount values

Return type:

List[float]

classmethod get_eq_HM_pcs_in_ph(ph)

Get the enthalpy per amount at equilibrium for all phase constituents in the specified phase.

Parameters:

ph (str | int) – phase name or zero-based index

Returns:

enthalpy per amount values

Return type:

List[float]

classmethod get_eq_HM_ph(ph)

Get the phase’s enthalpy per amount at equilibrium.

Parameters:

ph (str | int) – phase name or zero-based index

Returns:

enthalpy per amount value

Return type:

float

classmethod get_eq_HM_phs()

Get the enthalpy per amount at equilibrium for all phases.

Returns:

enthalpy per amount values

Return type:

List[float]

classmethod get_eq_H_pc(ph, pc)

Get the phase constituent’s enthalpy at equilibrium.

Parameters:
  • ph (str | int) – phase name or zero-based index

  • pc (str | int) – phase constituent name or zero-based index

Returns:

enthalpy value

Return type:

float

classmethod get_eq_H_pcs()

Get the enthalpy at equilibrium for all phase constituents.

Returns:

enthalpy values

Return type:

List[float]

classmethod get_eq_H_pcs_in_ph(ph)

Get the enthalpy at equilibrium for all phase constituents in the specified phase.

Parameters:

ph (str | int) – phase name or zero-based index

Returns:

enthalpy values

Return type:

List[float]

classmethod get_eq_H_ph(ph)

Get the phase’s enthalpy at equilibrium.

Parameters:

ph (str | int) – phase name or zero-based index

Returns:

enthalpy value

Return type:

float

classmethod get_eq_H_phs()

Get the enthalpy at equilibrium for all phases.

Returns:

enthalpy values

Return type:

List[float]

classmethod get_eq_IA_pc(ph, pc)

Get the phase constituent’s incoming amount at equilibrium.

Parameters:
  • ph (str | int) – phase name or zero-based index

  • pc (str | int) – phase constituent name or zero-based index

Returns:

incoming amount value

Return type:

float

classmethod get_eq_IA_pcs()

Get the incoming amount at equilibrium for all phase constituents.

Returns:

incoming amount values

Return type:

List[float]

classmethod get_eq_IA_pcs_in_ph(ph)

Get the incoming amount at equilibrium for all phase constituents in the specified phase.

Parameters:

ph (str | int) – phase name or zero-based index

Returns:

incoming amount values

Return type:

List[float]

classmethod get_eq_MU_pc(ph, pc)

Get the phase constituent’s chemical potential at equilibrium.

Parameters:
  • ph (str | int) – phase name or zero-based index

  • pc (str | int) – phase constituent name or zero-based index

Returns:

chemical potential value

Return type:

float

classmethod get_eq_MU_pcs()

Get the chemical potential at equilibrium for all phase constituents.

Returns:

chemical potential values

Return type:

List[float]

classmethod get_eq_MU_pcs_in_ph(ph)

Get the chemical potential at equilibrium for all phase constituents in the specified phase.

Parameters:

ph (str | int) – phase name or zero-based index

Returns:

chemical potential values

Return type:

List[float]

classmethod get_eq_MU_ph(ph)

Get the phase’s chemical potential at equilibrium.

Parameters:

ph (str | int) – phase name or zero-based index

Returns:

chemical potential value

Return type:

float

classmethod get_eq_MU_phs()

Get the chemical potential at equilibrium for all phases.

Returns:

chemical potential value

Return type:

List[float]

classmethod get_eq_MU_sc(sc)

Get the system component’s chemical potential at equilibrium.

Parameters:

sc (str | int) – system component name or zero-based index

Returns:

chemical potential value

Return type:

float

classmethod get_eq_MU_scs()

Get the chemical potential at equilibrium for all system components.

Returns:

list of chemical potential values

Return type:

List[float]

classmethod get_eq_P()

Get the system’s pressure at equilibrium.

Returns:

pressure value

Return type:

float

classmethod get_eq_S()

Get the system’s entropy at equilibrium.

Returns:

entropy value

Return type:

float

classmethod get_eq_SM()

Get the system’s entropy per amount at equilibrium.

Returns:

entropy per amount value

Return type:

float

classmethod get_eq_SM_pc(ph, pc)

Get the phase constituent’s entropy per amount at equilibrium.

Parameters:
  • ph (str | int) – phase name or zero-based index

  • pc (str | int) – phase constituent name or zero-based index

Returns:

entropy per amount value

Return type:

float

classmethod get_eq_SM_pcs()

Get the entropy per amount at equilibrium for all phase constituents.

Returns:

entropy per amount values

Return type:

List[float]

classmethod get_eq_SM_pcs_in_ph(ph)

Get the entropy per amount at equilibrium for all phase constituents in the specified phase.

Parameters:

ph (str | int) – phase name or zero-based index

Returns:

entropy per amount values

Return type:

List[float]

classmethod get_eq_SM_ph(ph)

Get the phase’s entropy per amount at equilibrium.

Parameters:

ph (str | int) – phase name or zero-based index

Returns:

entropy per amount value

Return type:

float

classmethod get_eq_SM_phs()

Get the entropy per amount at equilibrium for all phases.

Returns:

entropy per amount values

Return type:

List[float]

classmethod get_eq_S_pc(ph, pc)

Get the phase constituent’s entropy at equilibrium.

Parameters:
  • ph (str | int) – phase name or zero-based index

  • pc (str | int) – phase constituent name or zero-based index

Returns:

entropy value

Return type:

float

classmethod get_eq_S_pcs()

Get the entropy at equilibrium for all phase constituents.

Returns:

entropy value

Return type:

float

classmethod get_eq_S_pcs_in_ph(ph)

Get the entropy at equilibrium for all phase constituents in the specified phase.

Parameters:

ph (str | int) – phase name or zero-based index

Returns:

entropy values

Return type:

List[float]

classmethod get_eq_S_ph(ph)

Get the phase’s entropy at equilibrium.

Parameters:

ph (str | int) – phase name or zero-based index

Returns:

entropy value

Return type:

float

classmethod get_eq_S_phs()

Get the entropy at equilibrium for all phases.

Returns:

entropy value

Return type:

List[float]

classmethod get_eq_T()

et the system’s temperature at equilibrium.

Returns:

temperature value

Return type:

float

classmethod get_eq_V()

Get the system’s volume at equilibrium.

Returns:

volume value

Return type:

float

classmethod get_eq_VM()

Get the system’s volume per amount at equilibrium.

Returns:

volume per amount value

Return type:

float

classmethod get_eq_VM_pc(ph, pc)

Get the phase constituent’s volume per amount at equilibrium.

Parameters:
  • ph (str | int) – phase name or zero-based index

  • pc (str | int) – phase constituent name or zero-based index

Returns:

volume per amount value

Return type:

float

classmethod get_eq_VM_pcs()

Get the volume per amount at equilibrium for all phase constituents.

Returns:

volume per amount values

Return type:

List[float]

classmethod get_eq_VM_pcs_in_ph(ph)

Get the volume per amount at equilibrium for all phase constituents in the specified phase.

Parameters:

ph (str | int) – phase name or zero-based index

Returns:

volume per amount values

Return type:

List[float]

classmethod get_eq_VM_ph(ph)

Get the phase’s volume per amount at equilibrium.

Parameters:

ph (str | int) – phase name or zero-based index

Returns:

volume per amount value

Return type:

float

classmethod get_eq_VM_phs()

Get the volume per amount at equilibrium for all phases.

Returns:

volume per amount values

Return type:

List[float]

classmethod get_eq_VT()

Get the system’s total volume at equilibrium.

Returns:

total volume value

Return type:

float

classmethod get_eq_V_pc(ph, pc)

Get the phase constituent’s volume at equilibrium.

Parameters:
  • ph (str | int) – phase name or zero-based index

  • pc (str | int) – phase constituent name or zero-based index

Returns:

volume value

Return type:

float

classmethod get_eq_V_pcs()

Get the volume at equilibrium for all phase constituents.

Returns:

volume values

Return type:

List[float]

classmethod get_eq_V_pcs_in_ph(ph)

Get the volume at equilibrium for all phase constituents in the specified phase.

Parameters:

ph (str | int) – phase name or zero-based index

Returns:

volume value

Return type:

float

classmethod get_eq_V_ph(ph)

Get the phase’s volume at equilibrium.

Parameters:

ph (str | int) – phase name or zero-based index

Returns:

volume value

Return type:

float

classmethod get_eq_V_phs()

Get the volume at equilibrium for all phases.

Returns:

volume value

Return type:

List[float]

classmethod get_eq_X_sc(sc)

Get the system component’s amount fraction at equilibrium.

Parameters:

sc (str | int) – system component name or zero-based index

Returns:

amount fraction value

Return type:

float

classmethod get_eq_X_sc_in_ph(ph, sc)

Get the equilibrium amount fraction of the specified system component in the specified phase.

Parameters:
  • sc (str | int) – system component name or index

  • ph (str | int) – phase name or index

Returns:

amount fraction value

Return type:

float

classmethod get_eq_X_scs()

Get the amount fraction at equilibrium for all system components.

Returns:

list of amount fraction values

Return type:

List[float]

classmethod get_eq_X_scs_in_ph(ph)

Get the equilibrium amount fraction of all system components in the specified phase.

Parameters:
  • sc – system component name or index

  • ph (str | int) – phase name or index

Returns:

amount fraction value

Return type:

List[float]

classmethod get_result_object(result_type=chemapp.core.EquilibriumCalculationResult, error=False)

Extract an equilibrium calculation’s results in the form of a EquilibriumCalculationResult object.

The created object contains all system wide results as well as for each phase and system component, statically. These are static and not affected by any changes to the ThermochemicalSystem or EquilibriumCalculation classes.

Refer to the EquilibriumCalculationResult documentation for further information on how to use the results.

Parameters:
  • result_type – Default: EquilibriumCalculationResult, can be StreamCalculationResult. Only used for simpler inheritance.

  • error – Default: False, implies that results can be obtained. If True

Returns:

An object that contains the result of the last equilibrium calculation.

Return type:

EquilibriumCalculationResult

classmethod get_str_inputs()

Get the current set of ChemApp inputs as a string. This is the friendly equivalent of ChemApp’s tqshow() function.

Returns:

current ChemApp inputs (same as tqshow output)

Return type:

str

classmethod remove_eq_condition(number)

Remove an existing equilibrium condition.

Typically, the equilibrium condition number is returned from the respective condition setting call. Some conditions can not be removed. Generally, every condition can be replaced with a new value without being removed previously.

Parameters:

number (int) – The condition number

classmethod remove_eq_conditions_IA()

Remove all existing conditions related to incoming amounts. This includes incoming amounts (IA), chemical potentials (MU), and relative activities (AC). It does not remove system-level conditions or targets.

This is the equivalent of a call to tqremc(0)().

classmethod remove_eq_conditions_all()

Remove all existing equilibrium conditions.

This action removes all conditions, targets, and previously set configuration options.

This is the equivalent of a call to tqremc(-2)().

classmethod set_eq_A_ph(ph, value)

Set the phase’s equilibrium amount.

Parameters:
  • ph (str | int) – phase name or zero-based index

  • value (float) – amount value

Returns:

equilibrium condition number

Return type:

int

classmethod set_eq_Cp(value)

Set the equilibrium heat capacity for the system.

Parameters:

value (float) – heat capacity

Returns:

equilibrium condition number

Return type:

int

classmethod set_eq_Cp_ph(ph, value)

Set the phase’s equilibrium heat capacity.

Parameters:
  • ph (str | int) – phase name or zero-based index

  • value (float) – heat capacity value

Returns:

equilibrium condition number

Return type:

int

classmethod set_eq_G(value)

Set the equilibrium Gibbs energy for the system.

Parameters:

value (float) – Gibbs energy

Returns:

equilibrium condition number

Return type:

int

classmethod set_eq_G_ph(ph, value)

Set the phase’s equilibrium Gibbs energy.

Parameters:
  • ph (str | int) – phase name or zero-based index

  • value (float) – Gibbs energy value

Returns:

equilibrium condition number

Return type:

int

classmethod set_eq_H(value)

Set the equilibrium enthalpy for the system.

Parameters:

value (float) – enthalpy

Returns:

equilibrium condition number

Return type:

int

classmethod set_eq_H_ph(ph, value)

Set the phase’s equilibrium enthalpy.

Parameters:
  • ph (str | int) – phase name or zero-based index

  • value (float) – enthalpy value

Returns:

equilibrium condition number

Return type:

int

classmethod set_eq_P(value)

Set the equilibrium pressure for the system.

Parameters:

value (float) – pressure

Returns:

equilibrium condition number

Return type:

int

classmethod set_eq_S(value)

Set the equilibrium entropy for the system.

Parameters:

value (float) – entropy

Returns:

equilibrium condition number

Return type:

int

classmethod set_eq_S_ph(ph, value)

Set the phase’s equilibrium entropy.

Parameters:
  • ph (str | int) – phase name or zero-based index

  • value (float) – entropy value

Returns:

equilibrium condition number

Return type:

int

classmethod set_eq_T(value)

Set the equilibrium temperature for the system.

Parameters:

value (float) – temperature

Returns:

equilibrium condition number

Return type:

int

classmethod set_eq_V(value)

Set the equilibrium volume for the system.

Parameters:

value (float) – volume

Returns:

equilibrium condition number

Return type:

int

classmethod set_eq_VT(value)

Set the equilibrium total volume for the system.

Parameters:

value (float) – total volume

Returns:

equilibrium condition number

Return type:

int

classmethod set_eq_V_ph(ph, value)

Set the phase’s equilibrium volume.

Parameters:
  • ph (str | int) – phase name or zero-based index

  • value (float) – volume value

Returns:

equilibrium condition number

Return type:

int

class chemapp.friendly.Info

This class provides access to ChemApp functions that are used to get information about ChemApp itself, the user that it is licensed to, the license, and the array sizes that ChemApp uses to store data in memory.

The class is static, which means that you cannot create objects with it (e.g. info_object = Info()). The friendly module uses static classes as a convenient way to group ChemApp functions that perform related tasks together to make them easier to find and use.

classmethod get_array_size_max_dict()

Get ChemApp’s maximum internal array dimensions as a dictionary.

The keys are ‘na’, ‘nb’, ‘nc’, ‘nd’, ‘ne’, ‘nf’, ‘ng’, ‘nh’, ‘ni’, ‘nj’ and ‘nk’.

  • na: constituents

  • nb: system components

  • nc: mixture phases

  • nd: excess Gibbs energy coefficients for a mixture phase

  • ne: Excess magnetic coefficients for a mixture phase

  • nf: Sublattices of a mixture phase

  • ng: Constituents of a sublattice

  • nh: Oxide constituents of a phase described by the Gaye-Kapoor-Frohberg

    or modified quasichemical formalisms.

  • ni: Gibbs energy/heat capacity equations for a constituent

  • nk: Constituents with P,T-dependent molar volumes

Returns:

The internal array sizes of ChemApp

Return type:

Dict[str,int]

classmethod get_array_size_max_list()

Get ChemApp’s maximum internal array dimensions as a list.

Refer to get_array_size_max_dict() for a description of each value.

Returns:

The internal array sizes of ChemApp

Return type:

List[int]

classmethod get_array_size_max_str()

Print ChemApp’s maximum internal array dimensions to a string.

Returns:

A printable table of the array sizes of ChemApp

Return type:

str

classmethod get_array_size_used_dict()

Get ChemApp’s currently used internal array dimensions as a dictionary.

The keys are ‘na’, ‘nb’, ‘nc’, ‘nd’, ‘ne’, ‘nf’, ‘ng’, ‘nh’, ‘ni’, ‘nj’ and ‘nk’.

  • na: constituents

  • nb: system components

  • nc: mixture phases

  • nd: excess Gibbs energy coefficients for a mixture phase

  • ne: Excess magnetic coefficients for a mixture phase

  • nf: Sublattices of a mixture phase

  • ng: Constituents of a sublattice

  • nh: Oxide constituents of a phase described by the Gaye-Kapoor-Frohberg

    or modified quasichemical formalisms.

  • ni: Gibbs energy/heat capacity equations for a constituent

  • nk: Constituents with P,T-dependent molar volumes

Returns:

The currently used array sizes

Return type:

Dict[str, int]

classmethod get_array_size_used_list()

Get ChemApp’s currently used internal array dimensions as a list.

Refer to get_array_size_used_dict() for a description of each value.

Returns:

Currently used array sizes of ChemApp

Return type:

List[int]

classmethod get_array_size_used_str()

Print ChemApp’s currently used internal array dimensions to a string.

Returns:

A printable table of the array sizes of ChemApp

Return type:

str

Get the ChemApp copyright message.

Returns:

The copyright message

Return type:

str

classmethod get_dongle_id()

Get the ChemApp dongle id.

Returns:

ChemApp dongle id

Return type:

str

classmethod get_dongle_type()

Get the ChemApp dongle type.

Returns:

dongle type

Return type:

str

classmethod get_expiration_date()

Get the ChemApp license expiration date.

Returns:

(Month, Year) expiration date tuple.

Return type:

Tuple[int, int]

classmethod get_object()

Extract the information about ChemApp into a ChemAppInfo object.

Returns:

Class object containing all ChemApp information

Return type:

ChemAppInfo

classmethod get_program_id()

Get the ChemApp program ID.

Returns:

ChemApp program ID

Return type:

str

classmethod get_user_id()

Get the ChemApp user ID.

Returns:

User ID

Return type:

str

classmethod get_user_name()

Get the ChemApp user name.

Returns:

ChemApp user name, license holder.

Return type:

str

classmethod get_version_number()

Get the ChemApp version number.

Returns:

ChemApp version number

Return type:

int

classmethod is_light()

Indicates whether the Light version of ChemApp is being used.

This is only used as a failsafe in documentation examples and has no application for users.

Returns:

True if ChemApp light limitations apply

Return type:

bool

class chemapp.friendly.PhaseMapCalculation

Bases: AbsoluteEquilibriumCalculationBase

This abstract class provides base functionality for absolute equilibrium calculations, such as EquilibriumCalculation and PhaseMapCalculation.

StreamCalculation is classified as relative, since its streams provide initial conditions relative to which extensive variable changes can be calculated.

class IA_range

Bases: tuple

classmethod calculate_ph_txs_IA(IA_ranges, print_results=False)

Calculate the phase transitions given the specified incoming amount ranges.

Parameters:
  • IA_ranges (List[IA_range]) – list of PhaseMapCalculation.IA_range objects

  • print_results (bool) –

Returns:

one equilibrium calculation result for the lower boundary, upper boundary and each phase transition

Return type:

List[EquilibriumCalculationResult]

classmethod calculate_ph_txs_P(P_min, P_max, print_results=False)

Calculate the phase transitions given the minimum and maximum pressure.

Parameters:
  • Pmin – minimum pressure

  • Pmax – maximum pressure

  • P_min (float) –

  • P_max (float) –

  • print_results (bool) –

Returns:

one equilibrium calculation result for the lower boundary, upper boundary and each phase transition

Return type:

List[EquilibriumCalculationResult]

classmethod calculate_ph_txs_T(T_min, T_max, print_results=False)

Calculate the phase transitions given the minimum and maximum temperature.

Parameters:
  • Tmin – minimum temperature

  • Tmax – maximum temperature

  • T_min (float) –

  • T_max (float) –

  • print_results (bool) –

Returns:

one equilibrium calculation result for the lower boundary, upper boundary and each phase transition

Return type:

List[EquilibriumCalculationResult]

class chemapp.friendly.StreamCalculation

Bases: EquilibriumCalculationBase

This class provides base functionality share between all equilibrium calculation classes.

classmethod get_eq_V()

Get the system’s volume at equilibrium.

Note

This function will always give the system volume. The previous behavior, the difference in volume, can be accessed using get_eq_dV.

Returns:

volume value

Return type:

float

classmethod get_eq_dV()

Get the difference in volume between input streams and equilibrium result (reaction volume).

Returns:

volume value

Return type:

float

classmethod get_eq_G()

Get the system’s total gibbs energy at equilibrium.

Note

This function will always give the system total gibbs energy. The previous behavior, the difference in gibbs energy, can be accessed using get_eq_dG.

Returns:

total gibbs energy value

Return type:

float

classmethod get_eq_dG()

Get the difference in gibbs energy between input streams and equilibrium result (reaction gibbs energy).

Returns:

gibbs energy value

Return type:

float

classmethod get_eq_S()

Get the system’s total entropy at equilibrium.

Note

This function will always give the system total entropy. The previous behavior, the difference in entropy, can be accessed using get_eq_dS.

Returns:

entropy value

Return type:

float

classmethod get_eq_dS()

Get the difference in entropy between input streams and equilibrium result (reaction entropy).

Returns:

entropy value

Return type:

float

classmethod get_eq_H()

Get the system’s total enthalpy at equilibrium.

Note

This function will always give the system total enthalpy. The previous behavior, the difference in enthalpy, can be accessed using get_eq_dH.

Returns:

enthalpy value

Return type:

float

classmethod get_eq_dH()

Get the difference in enthalpy between input streams and equilibrium result (reaction enthalpy).

Returns:

enthalpy value

Return type:

float

classmethod get_eq_Cp()

Get the system’s total heat capacity at equilibrium.

Note

This function will always give the system total heat capacity. The previous behavior, the difference in heat capacity, can be accessed using get_eq_dCp.

Returns:

heat capacity value

Return type:

float

classmethod get_eq_dCp()

Get the difference in heat capacity between input streams and equilibrium result (reaction heat capacity).

Returns:

heat capacity value

Return type:

float

classmethod calculate_eq(print_results=False, estimate=False, return_result=False, **kwargs)

Do an equilibrium calculation.

Any keyword arguments from get_result_object() can be added.

Returns:

  • print_results – Indicates whether the results should be printed to console or not.

  • estimate – Indicates whether to use the previous calculation’s results as an initial estimate.

  • return_result – Indicates whether the routine immediately returns a ResultObject.

Parameters:
  • print_results (bool) –

  • estimate (bool) –

  • return_result (bool) –

Return type:

None | chemapp.core.StreamCalculationResult

classmethod calculate_eq_IA(IA_ranges, print_results=False)

Search for the target by adjusting the specified incoming amounts.

Parameters:
  • IA_ranges (List[Tuple[str, str, float, float]]) – Tuples of (Phase name, Phase constituent name, minimum amount, maximum amount)

  • print_results – default: False. Indicates whether the results should be directly printed or not.

classmethod calculate_eq_P(P_guess, print_results=False)

Search for the target by adjusting pressure, and use the provided guess as a starting value.

Parameters:
  • P_guess (float) – pressure guess value to start search

  • print_results (bool) – default: False. Indicates whether the results should be directly printed or not.

Returns:

pressure

Return type:

float

classmethod calculate_eq_T(T_guess, print_results=False)

Search for the target by adjusting temperature, and use the provided guess as a starting value.

Parameters:
  • T_guess (float) – temperature guess value to start search

  • print_results (bool) – default: False. Indicates whether the results should be directly printed or not.

Returns:

temperature

Return type:

float

classmethod calculate_eq_V(V_guess, print_results=False)

Search for the target by adjusting volume, and use the provided guess as a starting value.

Parameters:
  • V_guess – volume guess value to start search

  • print_results – default: False. Indicates whether the results should be directly printed or not.

Returns:

volume

Return type:

float

classmethod create_st(name, T, P)

Create a stream and set its temperature and pressure.

Parameters:
  • name (str) – name of the new stream

  • T (float) – temperature of the new stream

  • P (float) – pressure of the new stream

classmethod get_result_object(stream_extensive_properties=False, error=False)

Extract an equilibrium calculation’s results in the form of a StreamCalculationResult object.

The created object contains all system wide results as well as for each phase and system component, statically. These are static and not affected by any changes to the ThermochemicalSystem or StreamCalculation classes.

Refer to the StreamCalculationResult documentation for further information on how to use the results.

Parameters:
  • stream_extensive_properties (bool) – include stream extensive properties in the result object

  • error (bool) –

Returns:

An object that contains the result of the last stream calculation.

Return type:

StreamCalculationResult

classmethod get_st_Cp(name)

Get the specified stream’s heat capacity.

Parameters:

name (str) – stream name

Returns:

heat capacity value

Return type:

float

classmethod get_st_G(name)

Get the specified stream’s Gibbs energy.

Parameters:

name (str) – stream name

Returns:

Gibbs energy value

Return type:

float

classmethod get_st_H(name)

Get the specified stream’s enthalpy.

Parameters:

name (str) – stream name

Returns:

enthalpy value

Return type:

float

classmethod get_st_S(name)

Get the specified stream’s entropy.

Parameters:

name (str) – stream name

Returns:

entropy value

Return type:

float

classmethod get_st_V(name)

Get the specified stream’s volume.

Parameters:

name (str) – stream name

Returns:

volume value

Return type:

float

classmethod remove_st(st)

Remove the specified stream from ChemApp.

Parameters:

st (str) – stream name

classmethod remove_sts()

Remove all streams currently configured in ChemApp.

classmethod set_IA_pc(name, ph, pc, value)

Set the amount of the specified phase constituent in the specified phase.

Notice that this routine does not return the condition numbers.

Parameters:
  • name (str) – stream name

  • ph (str | int) – phase name or index

  • pc (str | int) – phase constituent name or index

  • value (float) – amount value

classmethod set_st(stream, name=None, A=-1.0)

Set up a stream based on a stream object.

If name is given, the name of the stream object is not used.

If A == -1.0 (or empty), the amount of the incoming stream object is used without modification.

Parameters:
classmethod set_target_formation_of_ph(ph)

Set the target as formation of the specified phase.

Parameters:

ph (str | int) – phase name or index

Returns:

equilibrium condition number

Return type:

int

classmethod set_target_precipitation_from_ph(ph)

Set the target as precipitation from the specified phase.

Parameters:

ph (str | int) – phase name or index

Returns:

equilibrium condition number

Return type:

int

classmethod set_tg_formation_of_ph(ph)

Set the target as formation of the specified phase. FutureWarning: This function is renamed to set_target_formation_of_ph. set_tg_formation_of_ph will be removed in a future version.

Deprecated since version 826: This function is renamed to set_target_formation_of_ph. set_tg_formation_of_ph will be removed in a future version.

Parameters:

ph (str | int) – phase name or index

Returns:

equilibrium condition number

Return type:

int

classmethod set_tg_precipitation_from_ph(ph)

Set the target as precipitation from the specified phase.

FutureWarning: This function is renamed to set_target_precipitation_from_ph. set_tg_precipitation_from_ph will be removed in a future version.

Deprecated since version 826: This function is renamed to set_target_precipitation_from_ph. set_tg_precipitation_from_ph will be removed in a future version.

Parameters:

ph (str | int) – phase name or index

Returns:

equilibrium condition number

Return type:

int

classmethod stream_reaction_result(streams, T=800.0, P=1.0)

Calculate the equilibrium for all streams at given temperatures and receive the result object directly.

Parameters:
  • streams (List[StreamState]) – streams to combine in calculation

  • T (float = 800.0) – temperature to calculate at, default=800

  • P (float = 1.0) – pressure to calculate at, default=1

Returns:

result object of the stream calculation

Return type:

StreamCalculationResult

class chemapp.friendly.ThermochemicalSystem

This class provides access to ChemApp functions that are used to perform tasks related to a loaded thermochemical system.

A thermochemical system is described by a data file that is loaded into ChemApp. Two data file types are used, namely ASCII and transparent. ASCII data files have .dat extensions, and transparent data file have .cst extensions. These files contain items such as system components, phases, phase constituents, thermochemical data, etc. Each transparent data file also contains a header, with more information about it, such as when it expires.

The class is static, which means that you cannot create objects with it (e.g. ts = ThermochemicalSystem()). The friendly module uses static classes as a convenient way to group ChemApp functions that perform related tasks together to make them easier to find and use.

classmethod get_config_pc(ph, pc)

Get the full configuration details of the specified phase.

Parameters:
  • ph (str | int) – phase name or zero-based index

  • pc (str | int) – phase constituent name or zero-based index

Returns:

configuration details object

Return type:

PhaseConstituentConfig

classmethod get_config_pcs_in_ph(ph)

Get the full configuration details of all phase constituents in the specified phase as a list of PhaseConstituentConfig objects.

Parameters:

ph (str | int) – phase name or zero-based index

Returns:

configuration details objects

Return type:

List[PhaseConstituentConfig]

classmethod get_config_ph(ph)

Get the full configuration details of the specified phase.

The PhaseConfig object contains a list of all PhaseConstituentConfig objects.

Parameters:

ph (str | int) – phase name or zero-based index

Returns:

configuration details object

Return type:

PhaseConfig

classmethod get_config_phs()

Get the full configuration details of all phases as a list of PhaseConfig objects.

Returns:

configuration details objects

Return type:

List[PhaseConfig]

classmethod get_config_sc(sc)

Get the full configuration details of the specified system component.

Parameters:

sc (str | int) – system component name or zero-based index

Returns:

configuration details object

Return type:

SystemComponentConfig

classmethod get_config_scs()

Get the full configuration details of all system components as a list of SystemComponentConfig objects.

Returns:

configuration details objects

Return type:

List[SystemComponentConfig]

classmethod get_count_pcs()

Get the total number of phase constituents in the system.

Returns:

number of phase constituents

Return type:

int

classmethod get_count_pcs_in_ph(ph)

Get the number of constituents in the specified phase.

Parameters:

ph (str | int) – phase name or zero-based index

Returns:

number of phase constituents in phase

Return type:

int

classmethod get_count_phs()

Get the number of phases.

Returns:

number of phases

Return type:

int

classmethod get_count_scs()

Get the number of system components.

Returns:

number of system components

Return type:

int

classmethod get_cst_info_dict()

Get information stored in the header of the currently loaded transparent file as a dictionary.

The dictionary contains the items listed in the following table.

Name

Type

Description

ver

int

version number of the transparent file header format

nwp

str

name of the program which wrote the data-file (40 chars)

vnw

int[3]

version number of the program which wrote the data-file

nrp

str

ID(s) of the programs which are permitted to read the data-file (40 chars)

vnr

int[3]

minimum version number of the reading program necessary to load the data-file

dtc

int[6]

creation date of the data-file

dte

int[6]

expiry date of the data-file

id

str

user ID(s) of the license holder(s) who are permitted to read this data-file (255 chars)

usr

str

name(s) of the license holder(s) who are permitted to read this data-file (80 chars)

rem

str

Returns the remark (80 chars)

Returns:

header information

Return type:

Dict[str, str | List[int] | int]

classmethod get_cst_info_str()

Print the information stored in the header of the currently loaded transparent file to a string.

The data being used in this printable information str can be acquired via get_cst_info_dict().

Returns:

Printable string representation.

Return type:

str

classmethod get_index_pc(ph, pc)

Get the index of the specified phase consituent in the specified phase.

Parameters:
  • ph (str | int) – phase name or zero-based index

  • pc (str | int) – phase constituent name or zero-based index

Returns:

number of phase constituents in phase

Return type:

int

classmethod get_index_ph(ph)

Get the index of the specified phase.

Parameters:

ph (str | int) – phase name or zero-based index

Returns:

index of phase

Return type:

int

classmethod get_index_sc(sc)

Get the index of the specified system component.

Parameters:

sc (str | int) – system component name or zero-based index

Returns:

index of system component

Return type:

int

classmethod get_mm_pc(ph, pc)

Get the molar mass of the specified phase consituent in the specified phase.

Notice that the result is in the units currently set. Typically, for a meaningful answer, changing the amount unit to grams is required. See class:Units

Parameters:
  • ph (str | int) – phase name or zero-based index

  • pc (str | int) – phase constituent name or zero-based index

Returns:

molar mass

Return type:

float

classmethod get_mm_pcs()

Get the molar masses of all phase constituents.

Returns:

molar masses

Return type:

List[float]

classmethod get_mm_pcs_in_ph(ph)

Get the molar mass of the phase consituents in the specified phase.

Parameters:

ph (str | int) – phase name or zero-based index

Returns:

molar masses

Return type:

List[float]

classmethod get_mm_sc(sc)

Get the molar mass of the specified system component.

Parameters:

sc (str | int) – system component name or zero-based index

Returns:

molar mass

Return type:

float

classmethod get_mm_scs()

Get the molar masses of all system components.

Returns:

molar masses

Return type:

List[float]

classmethod get_model_ph(ph)

Get the model name of the specified phase.

Parameters:

ph (str | int) – phase name or zero-based index

Returns:

enum of phase model

Return type:

SolutionModel

classmethod get_model_phs()

Get the solution models of all phases.

Returns:

enums of phase models

Return type:

List[SolutionModel]

classmethod get_name_pc(ph, pc)

Get the name of the specified phase constituent in the specified phase.

Yes you can use the name of the phase constituent for figuring out the name of the phase constituent.

Parameters:
  • ph (str | int) – phase name or zero-based index

  • pc (str | int) – phase constituent name or zero-based index

Returns:

phase constituent name

Return type:

str

classmethod get_name_pcs()

Get the names of all phase constituents.

Returns:

phase constituent names

Return type:

List[str]

classmethod get_name_pcs_in_ph(ph)

Get the names of all phase constituents in the specified phase.

Parameters:

ph (str | int) – phase name or zero-based index

Returns:

phase constituent names

Return type:

List[str]

classmethod get_name_ph(ph)

Get the name of the specified phase.

Parameters:

ph (str | int) – phase name or zero-based index

Returns:

phase name

Return type:

str

classmethod get_name_ph_pcs()

Get the names of all phases and phase constituents as a list of tuples.

Returns:

phase name, phase constituents list

Return type:

List[Tuple[str,str]]

classmethod get_name_phs()

Get the names of all phases.

Returns:

phase names

Return type:

List[str]

classmethod get_name_sc(sc)

Get the name of the specified system component.

Parameters:

sc (str | int) – system component name or zero-based index

Returns:

system component name

Return type:

str

classmethod get_name_scs()

Get the names of all system components.

Returns:

system component names

Return type:

List[str]

classmethod get_object()

Extract the currently loaded thermochemical system’s content into a ThermochemicalSystemConfig object.

Returns:

configuration object

Return type:

ThermochemicalSystemConfig

classmethod get_status_pc(ph, pc)

Get the status of the specified phase constituent in the specified phase.

Parameters:
  • ph (str | int) – phase name or zero-based index

  • pc (str | int) – phase constituent name or zero-based index

Returns:

status enumeration

Return type:

Status

classmethod get_status_pcs()

Get the statuses of all phase constituents.

Returns:

status enumerations

Return type:

List[Status]

classmethod get_status_pcs_in_ph(ph)

Get the statuses of all phase constituents in the specified phase.

Parameters:

ph (str | int) – phase name or zero-based index

Returns:

status enumerations

Return type:

List[Status]

classmethod get_status_ph(ph)

Get the status of the specified phase.

Parameters:

ph (str | int) – phase name or zero-based index

Returns:

status enumeration

Return type:

Status

classmethod get_status_phs()

Get the statuses of all phases.

Returns:

status enumerations

Return type:

List[Status]

classmethod get_stoich_pc(ph, pc, scs=None)

Get the stoichiometry of the specified phase consituent in the specified phase.

The order of the factors for the system components is determined by the loaded thermodynamic data file.

Parameters:
  • ph (str | int) – phase name or zero-based index

  • pc (str | int) – phase constituent name or zero-based index

  • scs – list of system components (names or zero-based indexes) to include in the result. (omission and None implies all)

Returns:

stoichiometric factors

Return type:

List[float]

classmethod get_stoich_pcs(scs=None)

Get the stoichiometry of all phase constituents.

The order of the factors for the system components as well as the order of the phase constituents is determined by the loaded thermodynamic data file.

Parameters:

scs (List[str]) – list of system components (names or zero-based indexes) to include in the result. (omission and None implies all)

Returns:

phase constituents stoichiometries

Return type:

List[List[float]]

classmethod get_stoich_pcs_in_ph(ph, scs=None)

Get the stoichiometry of the phase consituents in the specified phase.

The order of the factors for the system components as well as the order of the phase constituents is determined by the loaded thermodynamic data file.

Parameters:
  • ph (str | int) – phase name or zero-based index

  • scs – list of system components (names or zero-based indexes) to include in the result. (omission and None implies all)

Returns:

phase constituent stoichiometries

Return type:

List[List[float]]

classmethod get_stoich_sc(sc, scs=None)

Get the stoichiometry of the specified system component.

Since switching system components is discouraged, this routine is rarely applicable.

Parameters:
  • sc (str | int) – system component name or zero-based index

  • scs (List[str] | None) – list of system components (names or zero-based indexes) to include in the result. Omission and None implies all.

Returns:

system component stoichiometry

Return type:

List[float]

classmethod get_stoich_scs(scs=None)

Get the stoichiometry of all system components.

Parameters:

scs – list of system components (names or zero-based indexes) to include in the result. Omission and None implies all.

Returns:

system components stoichiometries

Return type:

List[List[float]]

classmethod get_str_phs()

Print a list of the phases in the loaded thermochemical system to a string.

Returns:

phases, printable

Return type:

str

classmethod get_str_phs_pcs()

Print a list of phases and phase constituents in the loaded thermochemical system to a string.”

Returns:

phases and phase constituents, printable

Return type:

str

classmethod get_str_scs()

Print a list of the system components in the loaded thermochemical system to a string.

Returns:

system components, printable

Return type:

str

classmethod get_y_sc_pc(ph, pc, sc)

Get the mass fraction of the specified system component in the specified phase constituent.

Parameters:
  • ph (str | int) – phase name or zero-based index

  • pc (str | int) – phase constituent name or zero-based index

  • sc (str | int) – system component name or zero-based index

Returns:

mass fraction

Return type:

float

classmethod get_y_sc_pcs(sc)

Get the mass fraction of the specified system component in all phase constituents.

Parameters:

sc (str | int) – system component name or zero-based index (str or float)

Returns:

mass fractions

Return type:

List[float]

classmethod get_y_sc_pcs_in_ph(ph, sc)

Get the mass fraction of the specified system component in the constituent of the specified phase.

Parameters:
  • ph (str | int) – phase name or zero-based index

  • sc (str | int) – system component name or zero-based index

Returns:

mass fractions

Return type:

List[float]

classmethod get_y_scs_pc(ph, pc, scs=None)

Get the mass fractions of the specified system components in the specified phase constituent.

Parameters:
  • ph (str | int) – phase name or zero-based index

  • pc (str | int) – phase constituent name or zero-based index

  • scs (List[str | float] | None) – list of system components (names or zero-based indexes) to include in the result. (omission and None implies all)

Returns:

mass fractions

Return type:

List[float]

classmethod get_y_scs_pcs(scs=None)

Get the mass fractions of the specified system components in all phase constituents.

Parameters:

scs (List[str | float] | None) – list of system components (names or zero-based indexes) to include in the result. (omission and None implies all)

Returns:

mass fractions

Return type:

List[List[float]]

classmethod get_y_scs_pcs_in_ph(ph, scs=None)

Get the mass fractions of the specified system components in the constituents of the specified phase.

Parameters:
  • ph (str | int) – phase name or zero-based index

  • scs (List[str | float] | None) – list of system components (names or zero-based indexes) to include in the result. (omission and None implies all)

Returns:

mass fractions

Return type:

List[List[float]]

classmethod load(file_path)

Initialise ChemApp and load the thermochemical data in the specified file.

The function performs these steps:

  • Initialise ChemApp (tqini())

  • Prevent errrors from being written to the console (tqcio())

  • Open, read and close the file

Take note of the default units after initialisation:

Pressure: bar Volume: dm3 Temperature: K Energy: J Amount: mol

Parameters:

file_path (str | os.PathLike) – file path, can be a string or a Path object

classmethod set_status_pc(ph, pc, status)

Set the status of the specified phase constituent in the specified phase to the specified value.

Parameters:
  • ph (str | int) – phase name or zero-based index

  • pc (str | int) – phase constituent name or zero-based index

  • status (chemapp.core.Status) – new status (ENTERED, DORMANT or ELIMINATE. Status enumeration)

classmethod set_status_pcs(status)

Set the statuses of all phase constituents to the specified value.

Parameters:

status (chemapp.core.Status) – new status (ENTERED, DORMANT or ELIMINATE. Status enumeration)

classmethod set_status_pcs_in_ph(ph, status)

Set the statuses of all phase constituents in the specified phase to the specified value.

Parameters:
  • ph (str | int) – phase name or zero-based index

  • status (chemapp.core.Status) – new status (ENTERED, DORMANT or ELIMINATE. Status enumeration)

classmethod set_status_ph(ph, status)

Set the status of the specified phase to the specified value.

Parameters:
  • ph (str | int) – phase name or zero-based index

  • status (chemapp.core.Status) – new status (ENTERED, DORMANT or ELIMINATE. Status enumeration)

classmethod set_status_phs(status)

Set the status of all phases to the specified value.

This routine can be used to reset the status of all phases.

Parameters:

status (chemapp.core.Status) – new status (ENTERED, DORMANT or ELIMINATE. Status enumeration)

class chemapp.friendly.Units

This class provides access to ChemApp functions that are used to perform tasks related unit of measure.

The class is static, which means that you cannot create objects with it (e.g. units = Units()). The friendly module uses static classes as a convenient way to group ChemApp functions that perform related tasks together to make them easier to find and use.

classmethod get()

Get ChemApp’s currently selected units of measure.

The keys are ‘P’, ‘V’, ‘T’, ‘E’, ‘A’ for pressure, volume, temperature, energy and amount.

The values are PressureUnit, VolumeUnit, TemperatureUnit, EnergyUnit or AmountUnit enums.

Returns:

currently selected units

Return type:

Dict[str, PressureUnit | VolumeUnit | TemperatureUnit | EnergyUnit | AmountUnit]

classmethod get_A_unit()

Get the amount unit of measure.

Returns:

current amount unit

Return type:

AmountUnit

classmethod get_E_unit()

Get the energy unit of measure.

Returns:

current energy unit

Return type:

EnerygUnit

classmethod get_P_unit()

Get the pressure unit of measure.

Returns:

current pressure unit

Return type:

PressureUnit

classmethod get_T_unit()

Get the temperature unit of measure.

Returns:

current temperature unit

Return type:

TemperatureUnit

classmethod get_V_unit()

Get the volume unit of measure.

Returns:

current volume unit

Return type:

VolumeUnit

classmethod get_str()

Print the current unit of measure used by ChemApp to a string.

Returns:

printable Units.

Return type:

str

classmethod set(P=..., V=..., T=..., E=..., A=...)

Set ChemApp’s unit of measure.

Using enumerations: PressureUnit, VolumeUnit, TemperatureUnit, EnergyUnit, AmountUnit

Parameters:
classmethod set_A_unit(unit)

Set the amount unit of measure.

Parameters:
classmethod set_E_unit(unit)

Set the energy unit of measure.

Parameters:
classmethod set_P_unit(unit)

Set the pressure unit of measure.

Parameters:
classmethod set_T_unit(unit)

Set the temperature unit of measure.

Parameters:
classmethod set_V_unit(unit)

Set the volume unit of measure.

Parameters:
classmethod use_chemapp_defaults()

Reset ChemApp to use the default units.

P: atm, T: C, V: m3, E: kWh, A: kg