libflash

Global

Components

class dartsflash.libflash.CompData

This class contains component specific data that is required for correlations in EoS and InitialGuess.

It contains a Units object that specifies the units of measurement for each of the properties.

class ConcentrationUnits

Unit for ion concentration

Members:

MOLALITY

WEIGHT

MOLALITY = <ConcentrationUnits.MOLALITY: 0>
WEIGHT = <ConcentrationUnits.WEIGHT: 1>
__init__(self: dartsflash.libflash.CompData.ConcentrationUnits, value: SupportsInt) None
CompData.ConcentrationUnits.name -> str
property value
MOLALITY = <ConcentrationUnits.MOLALITY: 0>
property Mw

List of component molar weight.

property Pc

List of component critical pressures Pc.

property T0

Ideal heat capacity reference temperature.

property Tc

List of component critical temperatures Tc.

WEIGHT = <ConcentrationUnits.WEIGHT: 1>
__init__(self: dartsflash.libflash.CompData, components: collections.abc.Sequence[str], salt_components: collections.abc.Sequence[str] = []) None

This is the constructor of CompData

Parameters:
  • components (list) – List of components

  • salt_components (list) – List of salt components

property ac

List of component acentric factors ac.

calculate_salt_composition(self: dartsflash.libflash.CompData, n: collections.abc.Sequence[typing.SupportsFloat], concentrations: collections.abc.Sequence[typing.SupportsFloat], mole_fractions: bool, unit: dartsflash.libflash.CompData.ConcentrationUnits = <ConcentrationUnits.MOLALITY: 0>) list[float]
Parameters:
  • n (list) – Composition vector

  • concentrations (list) – List of salt concentrations

  • mole_fractions (bool) – Output vector is mole fractions/mole numbers

  • unit (CompData::ConcentrationUnits) – Concentration unit (molality, weight fraction)

property charge

List of ion charges.

property components

Molecular species

property cpi

List of component ideal gas heat capacity coefficients.

property ions

Ionic species

property kij

List of lists of binary interaction coefficients.

property nc

Number of components.

property ni

Number of ions.

property ns

Number of species (components+salts).

property nsalt

Number of salt components.

property salt_components

Salt components

set_binary_coefficients(self: dartsflash.libflash.CompData, i: SupportsInt, kij: collections.abc.Sequence[SupportsFloat]) None

This is a function to set binary interaction coefficients for component i.

Parameters:
  • i (int) – Component index

  • kij (list) – List of binary interaction coefficients for component i

property species_with_ions

Molecular species + ions

property species_with_salts

Molecular species + salts

property units

Input/output units

property water_index

Index of water component, defaults to -1 if H2O is not present

Timer

class dartsflash.libflash.Timer

This class contains timers.

EOS = <timer.EOS: 3>
FLASH = <timer.FLASH: 0>
SPLIT = <timer.SPLIT: 2>
STABILITY = <timer.STABILITY: 1>
TOTAL = <timer.TOTAL: 4>
__init__(*args, **kwargs)
print_timers(self: dartsflash.libflash.Timer) None

This method prints all tracked timers.

start(self: dartsflash.libflash.Timer, key: dartsflash.libflash.Timer.timer) None
Parameters:

key (str) – Timer key

stop(self: dartsflash.libflash.Timer, key: dartsflash.libflash.Timer.timer) None
Parameters:

key (str) – Timer key

class timer

Timer keys

Members:

FLASH

STABILITY

SPLIT

EOS

TOTAL

EOS = <timer.EOS: 3>
FLASH = <timer.FLASH: 0>
SPLIT = <timer.SPLIT: 2>
STABILITY = <timer.STABILITY: 1>
TOTAL = <timer.TOTAL: 4>
__init__(self: dartsflash.libflash.Timer.timer, value: SupportsInt) None
Timer.timer.name -> str
property value

Units

class dartsflash.libflash.Units

This class contains units and performs unit conversions.

class ENERGY

Energy units

Members:

J

CAL

CAL = <ENERGY.CAL: 1>
J = <ENERGY.J: 0>
__init__(self: dartsflash.libflash.Units.ENERGY, value: SupportsInt) None
Units.ENERGY.name -> str
property value
class PRESSURE

Pressure units

Members:

BAR

PA

KPA

MPA

ATM

PSIA

ATM = <PRESSURE.ATM: 4>
BAR = <PRESSURE.BAR: 0>
KPA = <PRESSURE.KPA: 2>
MPA = <PRESSURE.MPA: 3>
PA = <PRESSURE.PA: 1>
PSIA = <PRESSURE.PSIA: 5>
__init__(self: dartsflash.libflash.Units.PRESSURE, value: SupportsInt) None
Units.PRESSURE.name -> str
property value
class TEMPERATURE

Temperature units

Members:

KELVIN

CELSIUS

FAHRENHEIT

RANKINE

CELSIUS = <TEMPERATURE.CELSIUS: 1>
FAHRENHEIT = <TEMPERATURE.FAHRENHEIT: 2>
KELVIN = <TEMPERATURE.KELVIN: 0>
RANKINE = <TEMPERATURE.RANKINE: 3>
__init__(self: dartsflash.libflash.Units.TEMPERATURE, value: SupportsInt) None
Units.TEMPERATURE.name -> str
property value
class VOLUME

Volume units

Members:

M3

CM3

L

FT3

CM3 = <VOLUME.CM3: 1>
FT3 = <VOLUME.FT3: 3>
L = <VOLUME.L: 2>
M3 = <VOLUME.M3: 0>
__init__(self: dartsflash.libflash.Units.VOLUME, value: SupportsInt) None
Units.VOLUME.name -> str
property value
__init__(self: dartsflash.libflash.Units, pressure: dartsflash.libflash.Units.PRESSURE = <PRESSURE.BAR: 0>, temperature: dartsflash.libflash.Units.TEMPERATURE = <TEMPERATURE.KELVIN: 0>, volume: dartsflash.libflash.Units.VOLUME = <VOLUME.M3: 0>, energy: dartsflash.libflash.Units.ENERGY = <ENERGY.J: 0>) None

This is the constructor of Units.

Parameters:
  • pressure – Pressure unit, default is BAR

  • temperature – Temperature unit, default is KELVIN

  • volume – Volume unit, default is M3

  • energy – Energy unit, default is J

Flash methods

class dartsflash.libflash.FlashParams

This is a class that contains all required parameters that can be passed to a flash algorithm.

ALL = <VerboseLevel.ALL: 5>
BRENT = <PXFlashType.BRENT: 0>
BRENT_NEWTON = <PXFlashType.BRENT_NEWTON: 1>
ERROR = <VerboseLevel.ERROR: 1>
G_pure(self: dartsflash.libflash.FlashParams, arg0: SupportsFloat, arg1: SupportsFloat) list[float]
H_pure(self: dartsflash.libflash.FlashParams, arg0: SupportsFloat, arg1: SupportsFloat) list[float]
NONE = <VerboseLevel.NONE: 0>
class PXFlashType

Root finding algorithm for PXFlash

Members:

BRENT

BRENT_NEWTON

BRENT = <PXFlashType.BRENT: 0>
BRENT_NEWTON = <PXFlashType.BRENT_NEWTON: 1>
__init__(self: dartsflash.libflash.FlashParams.PXFlashType, value: SupportsInt) None
FlashParams.PXFlashType.name -> str
property value
class SplitVars

Primary variables for phase split

Members:

nik

lnK

lnK_chol

__init__(self: dartsflash.libflash.FlashParams.SplitVars, value: SupportsInt) None
lnK = <SplitVars.lnK: 1>
lnK_chol = <SplitVars.lnK_chol: 2>
FlashParams.SplitVars.name -> str
nik = <SplitVars.nik: 0>
property value
class StabilityVars

Primary variables for stability

Members:

Y

lnY

alpha

Y = <StabilityVars.Y: 0>
__init__(self: dartsflash.libflash.FlashParams.StabilityVars, value: SupportsInt) None
alpha = <StabilityVars.alpha: 2>
lnY = <StabilityVars.lnY: 1>
FlashParams.StabilityVars.name -> str
property value
property T_init

Initial temperature for PXFlash

property T_max

Maximum temperature for PXFlash

property T_min

Minimum temperature for PXFlash

class VerboseLevel

Verbose level for logging

Members:

NONE

ERROR

WARNING

WORKFLOW

WORKFLOW_AND_RESULTS

ALL

ALL = <VerboseLevel.ALL: 5>
ERROR = <VerboseLevel.ERROR: 1>
NONE = <VerboseLevel.NONE: 0>
WARNING = <VerboseLevel.WARNING: 2>
WORKFLOW = <VerboseLevel.WORKFLOW: 3>
WORKFLOW_AND_RESULTS = <VerboseLevel.WORKFLOW_AND_RESULTS: 4>
__init__(self: dartsflash.libflash.FlashParams.VerboseLevel, value: SupportsInt) None
FlashParams.VerboseLevel.name -> str
property value
WARNING = <VerboseLevel.WARNING: 2>
WORKFLOW = <VerboseLevel.WORKFLOW: 3>
WORKFLOW_AND_RESULTS = <VerboseLevel.WORKFLOW_AND_RESULTS: 4>
Y = <StabilityVars.Y: 0>
__init__(self: dartsflash.libflash.FlashParams, comp_data: dartsflash.libflash.CompData) None
Parameters:

comp_data (CompData) – Component data object

add_eos(self: dartsflash.libflash.FlashParams, name: str, eos: dartsflash.libflash.EoS) None

Add EoSParams object to map. This function creates a copy of the EoS object inside the EoSParams struct.

Parameters:
  • name (str) – EoS name

  • eos (EoS) – EoS object

alpha = <StabilityVars.alpha: 2>
property comp_tol

Tolerance for comparing compositions

property eos_order

Order of EoS for output

property eos_params

Map of EoSParams object associated with each EoS object

find_pure_phase(self: dartsflash.libflash.FlashParams, p: SupportsFloat, T: SupportsFloat, Gpure: collections.abc.Sequence[SupportsFloat]) list[str]

Find pure phases at state (P,T)

Parameters:
  • p (float) – Pressure

  • T (float) – Temperature

  • Gpure (list) – List of pure component Gibbs free energies

find_ref_comp(*args, **kwargs)

Overloaded function.

  1. find_ref_comp(self: dartsflash.libflash.FlashParams, p: typing.SupportsFloat, T: typing.SupportsFloat, z: collections.abc.Sequence[typing.SupportsFloat], ref_comp: dartsflash.libflash.TrialPhase, nonzero_comp_idxs: collections.abc.Sequence[typing.SupportsInt]) -> bool

    Find stable phase at state (P,T,n)

    param p:

    Pressure

    type p:

    float

    param T:

    Temperature

    type T:

    float

    param z:

    Feed composition

    type z:

    list

    param ref_comp:

    TrialPhase object that contains reference composition

    type ref_comp:

    TrialPhase

  2. find_ref_comp(self: dartsflash.libflash.FlashParams, p: typing.SupportsFloat, T: typing.SupportsFloat, z: collections.abc.Sequence[typing.SupportsFloat], ref_comps: collections.abc.Sequence[dartsflash.libflash.TrialPhase]) -> bool

    Find projection of feed composition to subspace/lower dimensions at state (P,T,n)

    param p:

    Pressure

    type p:

    float

    param T:

    Temperature

    type T:

    float

    param z:

    Feed composition

    type z:

    list

    param ref_comps:

    List of TrialPhase objects that contains projections

    type ref_comps:

    list

get_phase_state(*args, **kwargs)

Overloaded function.

  1. get_phase_state(self: dartsflash.libflash.FlashParams, phase_idxs: collections.abc.Sequence[typing.SupportsInt]) -> int

    Get phase state id. This function calculates binary id of phase idxs and returns phase state id.

    param phase_idxs:

    List of phase idxs

    returns:

    Phase state id

    rtype:

    int

  2. get_phase_state(self: dartsflash.libflash.FlashParams, phase_state: typing.SupportsInt) -> str

    Get phase state string from phase_states_map

    param phase_state:

    Phase state id

    returns:

    Phase state name

    rtype:

    str

init_eos(self: dartsflash.libflash.FlashParams, p: SupportsFloat, T: SupportsFloat) None

Initialize EoS parameters at (P,T)

Parameters:
  • p (double) – Pressure

  • T (double) – Temperature

property light_comp_idx

Index of lightest component to perform initial guess on for vapour phase identification

lnK = <SplitVars.lnK: 1>
lnK_chol = <SplitVars.lnK_chol: 2>
lnY = <StabilityVars.lnY: 1>
property min_z

Minimum value for composition

property modChol_split

Switch for modified Cholesky iterations in split

property modChol_stability

Switch for modified Cholesky iterations in split

property near_zero_pt

Composition threshold for option to initialize PT-flash with all components z[i] > near_zero_pt, then use results as input for all components, default is NAN which skips this logic

property near_zero_px

Composition threshold for option to initialize PX-flash with all components z[i] > near_zero_pt, then use results as input for all components, default is NAN which skips this logic

nik = <SplitVars.nik: 0>
property np_max

Maximum number of phases according to EoS order, root and rich phase order

property phase_boundary_Gtol

|Ga-Gb| < Gtol

Type:

Function tolerance for locating equal Gibbs energies

property phase_boundary_Ttol

Tmax-Tmin < Ttol

Type:

Temperature tolerance for locating equal Gibbs energies

property phase_states_str

Vector of phase state names

prop_1p(self: dartsflash.libflash.FlashParams, arg0: dartsflash.libflash.EoS.Potential, arg1: SupportsFloat, arg2: SupportsFloat, arg3: collections.abc.Sequence[SupportsFloat], arg4: collections.abc.Sequence[SupportsInt], arg5: collections.abc.Sequence[SupportsInt]) list[float]
prop_np(self: dartsflash.libflash.FlashParams, arg0: dartsflash.libflash.EoS.Potential, arg1: SupportsFloat, arg2: SupportsFloat, arg3: collections.abc.Sequence[SupportsFloat], arg4: collections.abc.Sequence[SupportsInt], arg5: collections.abc.Sequence[SupportsInt]) list[float]
prop_pure(self: dartsflash.libflash.FlashParams, arg0: dartsflash.libflash.EoS.Potential, arg1: SupportsFloat, arg2: SupportsFloat) list[float]
property pxflash_Ftol

|X-Xspec| < Ftol

Type:

Function tolerance for specification equation in PXFlash

property pxflash_Ttol

Tmax-Tmin < Ttol

Type:

Temperature tolerance for switch to locate_phase_boundary in PXFlash

property pxflash_switch_Ttol

Tolerance for temperature to switch to PXFlash phase boundary logic, default is NAN which skips this logic

property pxflash_type
  1. BRENT, 1) BRENT_NEWTON

Type:

Root finding algorithm for PXFlash

property rr2_tol

Tolerance for two-phase Rachford-Rice norm

property rr_max_iter

Maximum number of iterations for Rachford-Rice procedure

property rrn_tol

Tolerance for N-phase Rachford-Rice norm

property save_performance_data

Option to save performance data of the flash

set_eos_order(self: dartsflash.libflash.FlashParams, eos_order: collections.abc.Sequence[str]) None

Set order of EoS. This function counts the maximum number of phases and creates a map of unique phase states.

Parameters:

name – List of EoS names

set_pure_phase_flash_params(*args, **kwargs)

Overloaded function.

  1. set_pure_phase_flash_params(self: dartsflash.libflash.FlashParams, pure_comp_name: str, pure_phase_name: str, ref_comp_name: str, ref_phase_name: str, z_min: typing.SupportsFloat, z_max: typing.SupportsFloat) -> None

    Set parameters for pure phase flash loop. It specifies index of pure component i, its pure phase, index of reference component and a reference phase. Using this method, z_min/z_max are evaluated as composition bounds relative to z[j].

    param pure_comp_name:

    Pure component name

    param pure_phase_name:

    Pure phase name

    param ref_comp_name:

    Other component relative to which composition bounds are determined (e.g., H2O for salt)

    param ref_phase_name:

    Reference phase that must be present for root-finding loop (e.g., aqueous phase for salt)

    param z_min:

    Minimum composition

    param z_max:

    Maximum composition

  2. set_pure_phase_flash_params(self: dartsflash.libflash.FlashParams, pure_comp_name: str, pure_phase_name: str, z_min: typing.SupportsFloat, z_max: typing.SupportsFloat) -> None

    Set parameters for pure phase flash loop. It specifies index of pure component i and its pure phase. Using this method, z_min/z_max are evaluated as absolute composition bounds.

    param pure_comp_name:

    Pure component name

    param pure_phase_name:

    Pure phase name

    param z_min:

    Minimum composition

    param z_max:

    Maximum composition

property split_line_iter

Maximum number of iterations for line search in phase split

property split_line_tol

Tolerance for line search in phase split

property split_max_iter

Maximum number of iterations for phase split

property split_negative_flash_iter

Number of iterations to quit split if negative flash

property split_switch_diff

If decrease in log(norm) between two SSI iterations is below this number (and tol < switch_tol), switch to Newton - make use of effectiveness of SSI

property split_switch_tol

Tolerance for switch to Newton in phase split

property split_tol

Tolerance for phase split norm

property split_variables
  1. n_ik, 1) lnK, 2) lnK-chol

Type:

Variables for phase split

property stability_variables
  1. Y, 1) lnY, 2) alpha

Type:

Variables for stability

property timer

Timer object

property tpd_1p_tol

Tolerance to determine limit for tpd that is considered stable

property tpd_close_to_boundary

Tolerance to check if too close to phase boundary and switch PhaseSplit variables

property tpd_tol

Tolerance for comparing tpd; also used to determine limit for tpd that is considered stable

property units

Units object

property verbose

Verbose level

property vl_eos_name

Name of VL EoS object for phase identification

Flash

class dartsflash.libflash.Flash

This is a base class for Flash.

Each Flash child class overrides the methods for evaluate(p, T, z).

__init__(self: dartsflash.libflash.Flash, flashparams: FlashParams) None

This is the constructor of the Flash base class.

Parameters:

flashparams (FlashParams) – Flash parameters object

evaluate(self: dartsflash.libflash.Flash, p: SupportsFloat, T: SupportsFloat, z: collections.abc.Sequence[SupportsFloat], flash_results: FlashResults = None) int

Evaluate multicomponent flash at (P, T, z), optionally starting from (extrapolated) previous results

Parameters:
  • p (double) – Pressure

  • T (double) – Temperature

  • z (list) – Feed composition

  • flash_results (FlashResults) – FlashResults object of (extrapolated) previous results, default is nullptr which makes it initialize from feed

Returns:

Error output of flash procedure

Return type:

int

extrapolate_flash_results(self: dartsflash.libflash.Flash, p: SupportsFloat, T: SupportsFloat, z: collections.abc.Sequence[SupportsFloat], flash_results: FlashResults) FlashResults
Parameters:
  • p (double) – New pressure

  • T (double) – New temperature

  • z (list) – New feed composition

  • flash_results (FlashResults) – FlashResults object of previous results

Returns:

Extrapolated FlashResults

Return type:

FlashResults

find_stationary_points(self: dartsflash.libflash.Flash, p: SupportsFloat, T: SupportsFloat, X: collections.abc.Sequence[SupportsFloat]) list[dartsflash.libflash.TrialPhase]

Determine stationary points of TPD function at (multiphase) composition X

Parameters:
  • p (double) – Pressure

  • T (double) – Temperature

  • X (list) – List of reference compositions

Returns:

Set of stationary points

Return type:

list

get_flash_results(self: dartsflash.libflash.Flash, derivs: bool = False) FlashResults
Returns:

Results of flash

Return type:

FlashResults

Stability

class dartsflash.libflash.Stability

This is the base class for performing stability tests.

__init__(self: dartsflash.libflash.Stability, flash_params: dartsflash.libflash.FlashParams) None
Parameters:
  • flash_params – FlashParams object

  • nonzero_comp_idxs (list) – List of indices of active/nonzero components, default is empty which defaults to all idxs

init(self: dartsflash.libflash.Stability, ref_comps: collections.abc.Sequence[dartsflash.libflash.TrialPhase], ref_idx: SupportsInt = 0) None

Initialise stability algorithm at p, T, with reference phase compositions

Parameters:
  • ref_comps (list of TrialPhase objects) – List of reference phases.

  • ref_idx (int) – Reference composition index (in case of reduced dimensions)

run(self: dartsflash.libflash.Stability, trial_comp: dartsflash.libflash.TrialPhase, gmix_min: bool = False) int

Run stability test from trial phase composition initial guess Y.

Parameters:
  • trial_comp (TrialPhase object) – Trial phase

  • gmix_min (bool) – Switch for finding minimum of Gmix surface

PhaseSplit

Rachford-Rice

class dartsflash.libflash.RR

This is the base class for solving the Rachford-Rice equation.

__init__(self: dartsflash.libflash.RR, np: SupportsInt, nc: SupportsInt, min_z: SupportsFloat = 1e-10, rr_tol: SupportsFloat = 1e-12, loose_tol: SupportsFloat = 1000.0, max_iter: SupportsInt = 100, loose_iter: SupportsInt = 10, verbose: bool = False, nonzero_comp_idxs: collections.abc.Sequence[SupportsInt] = None) None
Parameters:
  • np (int) – Number of phases

  • nc (int) – Number of components

  • min_z

  • rr_tol

  • loose_tol

  • max_iter

  • loose_iter

  • verbose

  • nonzero_comp_idxs (list) – List of indices of active/nonzero components, default is empty which defaults to all idxs

getnu(self: dartsflash.libflash.RR) list[float]
Returns:

List of phase fractions

Return type:

list

getx(self: dartsflash.libflash.RR) list[float]
Returns:

List of phase compositions

Return type:

list

solve_rr(self: dartsflash.libflash.RR, z: collections.abc.Sequence[SupportsFloat], K: collections.abc.Sequence[SupportsFloat], ref_idxs: collections.abc.Sequence[SupportsInt] = None) int

This function solves the N-phase RR equation

Parameters:
  • z (list) – List of feed composition

  • K (list) – List of equilibrium constants K

  • ref_idxs (list) – List of reference phases for equilibrium constants K of each component

Returns:

Error output of RR-procedure

Return type:

int

class dartsflash.libflash.RR_EqConvex2

This is the two-phase negative flash implementation based on equation solving with convex transformations.

For reference, see Nichita and Leibovici (2013).

__init__(self: dartsflash.libflash.RR_EqConvex2, nc: SupportsInt, min_z: SupportsFloat = 1e-10, rr_tol: SupportsFloat = 1e-12, loose_tol: SupportsFloat = 1000.0, max_iter: SupportsInt = 100, loose_iter: SupportsInt = 10, verbose: bool = False, nonzero_comp_idxs: collections.abc.Sequence[SupportsInt] = None) None
Parameters:
  • nc (int) – Number of components

  • min_z

  • rr_tol

  • loose_tol

  • max_iter

  • loose_iter

  • verbose

  • nonzero_comp_idxs (list) – List of indices of active/nonzero components, default is empty which defaults to all idxs

class dartsflash.libflash.RR_Min

This is the multiphase RR implementation based on minimization.

For reference, see Michelsen (1994) and Yan and Stenby (2012).

__init__(self: dartsflash.libflash.RR_Min, np: SupportsInt, nc: SupportsInt, min_z: SupportsFloat = 1e-10, rr_tol: SupportsFloat = 1e-12, loose_tol: SupportsFloat = 1000.0, max_iter: SupportsInt = 100, loose_iter: SupportsInt = 10, verbose: bool = False, nonzero_comp_idxs: collections.abc.Sequence[SupportsInt] = None) None
Parameters:
  • np (int) – Number of phases

  • nc (int) – Number of components

  • min_z

  • rr_tol

  • loose_tol

  • max_iter

  • loose_iter

  • verbose

  • nonzero_comp_idxs (list) – List of indices of active/nonzero components, default is empty which defaults to all idxs

Equations of State

EoS

class dartsflash.libflash.EoS

This is a base class for Equations of State (EoS).

Each EoS child class overrides the methods for: - (P,T)-dependent parameters in init_PT(p, T) - (n)-dependent parameters in solve_PT(n) - Expressions for lnphi(i) and derivatives w.r.t. P, T, nj - Expressions for Gibbs free energy Gr and enthalpy Hr

Cp(self: dartsflash.libflash.EoS, X: SupportsFloat, T: SupportsFloat, n: collections.abc.Sequence[SupportsFloat], start_idx: SupportsInt = 0, pt: bool = True) float
Parameters:
  • X (double) – Pressure

  • T (double) – Temperature

  • n (list) – Composition

  • start_idx (int) – Index of n[0], default is 0

  • pt (bool) – Calculate PT-based (true) or VT-based (false) property

Returns:

Heat capacity at constant pressure Cp of mixture at (P,T,n)/(V,T,n)

Return type:

double

ENTHALPY = <Potential.ENTHALPY: 2>
ENTROPY = <Potential.ENTROPY: 0>
G(self: dartsflash.libflash.EoS, X: SupportsFloat, T: SupportsFloat, n: collections.abc.Sequence[SupportsFloat], start_idx: SupportsInt = 0, pt: bool = True) float
Parameters:
  • X (double) – Pressure/Volume

  • T (double) – Temperature

  • n (list) – Composition

  • start_idx (int) – Index of n[0], default is 0

  • pt (bool) – Calculate PT-based (true) or VT-based (false) property

Returns:

Total Gibbs free energy G of mixture at (P,T,n)/(V,T,n)

Return type:

double

GIBBS = <Potential.GIBBS: 1>
H(self: dartsflash.libflash.EoS, X: SupportsFloat, T: SupportsFloat, n: collections.abc.Sequence[SupportsFloat], start_idx: SupportsInt = 0, pt: bool = True) float
Parameters:
  • X (double) – Pressure/Volume

  • T (double) – Temperature

  • n (list) – Composition

  • start_idx (int) – Index of n[0], default is 0

  • pt (bool) – Calculate PT-based (true) or VT-based (false) property

Returns:

Total enthalpy H of mixture at (P,T,n)/(V,T,n)

Return type:

double

HELMHOLTZ = <Potential.HELMHOLTZ: 3>
INTERNAL_ENERGY = <Potential.INTERNAL_ENERGY: 4>
MAX = <RootFlag.MAX: 1>
MIN = <RootFlag.MIN: 0>
P(self: dartsflash.libflash.EoS, V: SupportsFloat, T: SupportsFloat, n: collections.abc.Sequence[SupportsFloat], start_idx: SupportsInt = 0, pt: bool = False) float
Parameters:
  • V (double) – Volume

  • T (double) – Temperature

  • n (list) – Composition

  • start_idx (int) – Index of n[0], default is 0

  • pt (bool) – Calculate PT-based (true) or VT-based (false) property

Returns:

Pressure of mixture at (V,T,n)

Return type:

double

class Potential

Enum for thermodynamic potential to be calculated from EoS

Members:

ENTROPY

GIBBS

ENTHALPY

HELMHOLTZ

INTERNAL_ENERGY

ENTHALPY = <Potential.ENTHALPY: 2>
ENTROPY = <Potential.ENTROPY: 0>
GIBBS = <Potential.GIBBS: 1>
HELMHOLTZ = <Potential.HELMHOLTZ: 3>
INTERNAL_ENERGY = <Potential.INTERNAL_ENERGY: 4>
__init__(self: dartsflash.libflash.EoS.Potential, value: SupportsInt) None
EoS.Potential.name -> str
property value
class RootFlag

Flag for roots to be selected in EoS

Members:

STABLE

MIN

MAX

MAX = <RootFlag.MAX: 1>
MIN = <RootFlag.MIN: 0>
STABLE = <RootFlag.STABLE: -1>
__init__(self: dartsflash.libflash.EoS.RootFlag, value: SupportsInt) None
EoS.RootFlag.name -> str
property value
S(self: dartsflash.libflash.EoS, X: SupportsFloat, T: SupportsFloat, n: collections.abc.Sequence[SupportsFloat], start_idx: SupportsInt = 0, pt: bool = True) float
Parameters:
  • X (double) – Pressure/Volume

  • T (double) – Temperature

  • n (list) – Composition

  • start_idx (int) – Index of n[0], default is 0

  • pt (bool) – Calculate PT-based (true) or VT-based (false) property

Returns:

Total entropy S of mixture at (P,T,n)/(V,T,n)

Return type:

double

STABLE = <RootFlag.STABLE: -1>
V(self: dartsflash.libflash.EoS, p: SupportsFloat, T: SupportsFloat, n: collections.abc.Sequence[SupportsFloat], start_idx: SupportsInt = 0, pt: bool = True) float
Parameters:
  • p (double) – Pressure

  • T (double) – Temperature

  • n (list) – Composition

  • start_idx (int) – Index of n[0], default is 0

  • pt (bool) – Calculate PT-based (true) or VT-based (false) property

Returns:

Molar volume of mixture at (P,T,n)

Return type:

double

Z(self: dartsflash.libflash.EoS, X: SupportsFloat, T: SupportsFloat, n: collections.abc.Sequence[SupportsFloat], start_idx: SupportsInt = 0, pt: bool = True) float
Parameters:
  • X (double) – Pressure/Volume

  • T (double) – Temperature

  • n (list) – Composition

  • start_idx (int) – Index of n[0], default is 0

  • pt (bool) – Calculate PT-based (true) or VT-based (false) property

Returns:

Compressibility factor Z of mixture at (P,T,n)/(V,T,n)

Return type:

double

__init__(self: dartsflash.libflash.EoS, comp_data: CompData) None

This is the constructor of the EoS base class for multicomponent phases.

Parameters:

comp_data (CompData) – Component data

calc_condition_number(self: dartsflash.libflash.EoS, p: SupportsFloat, T: SupportsFloat, n: collections.abc.Sequence[SupportsFloat], start_idx: SupportsInt = 0) float

Function to determine condition number of Hessian matrix to evaluate curvature of GE/TPD surface at P, T and composition n.

Parameters:
  • p (double) – Pressure

  • T (double) – Temperature

  • n (list) – Composition

  • start_idx (int) – Index of n[0], default is 0

Return type:

bool

dlnphi_dP(self: dartsflash.libflash.EoS) list[float]
Returns:

List of dlnphi/dP for each component at (P,T,n)

Return type:

list

dlnphi_dT(self: dartsflash.libflash.EoS) list[float]
Returns:

List of dlnphi/dT for each component at (P,T,n)

Return type:

list

fugacity(self: dartsflash.libflash.EoS, p: SupportsFloat, T: SupportsFloat, x: collections.abc.Sequence[SupportsFloat], start_idx: SupportsInt = 0, pt: bool = True) list[float]

Calculate mixture fugacity at (P,T,x)

Parameters:
  • p (double) – Pressure

  • T (double) – Temperature

  • x (list) – Composition

  • start_idx (int) – Index of n[0], default is 0

  • pt (bool) – Calculate PT-based (true) or VT-based (false) property

Returns:

List of component fugacities

Return type:

list

get_comp_data(self: dartsflash.libflash.EoS) CompData

Getter for CompData object reference

is_convex(self: dartsflash.libflash.EoS, p: typing.SupportsFloat, T: typing.SupportsFloat, n: collections.abc.Sequence[typing.SupportsFloat], start_idx: typing.SupportsInt = 0, root_flag: dartsflash.libflash.EoS.RootFlag = <RootFlag.STABLE: -1>) bool

Function to determine if GE/TPD surface at composition is convex.

Parameters:
  • p (double) – Pressure

  • T (double) – Temperature

  • n (list) – Composition

  • start_idx (int) – Index of n[0], default is 0

  • root_flag (EoS::RootFlag) – Root type to evaluate

Return type:

bool

is_root_type(self: dartsflash.libflash.EoS, p: SupportsFloat, T: SupportsFloat, n: collections.abc.Sequence[SupportsFloat], is_below_spinodal: bool, start_idx: SupportsInt = 0, pt: bool = True) dartsflash.libflash.EoS.RootFlag
Parameters:
  • X (double) – Pressure/Volume

  • T (double) – Temperature

  • n (list) – Composition

  • start_idx (int) – Index of n[0], default is 0

  • pt (bool) – Calculate PT-based (true) or VT-based (false) property

Returns:

Root type

Return type:

EoS.RootFlag

lnphi(self: dartsflash.libflash.EoS, p: SupportsFloat, T: SupportsFloat, n: collections.abc.Sequence[SupportsFloat]) list[float]
Returns:

List of lnphi for each component at (P,T,n)

Return type:

list

rho(self: dartsflash.libflash.EoS, X: SupportsFloat, T: SupportsFloat, n: collections.abc.Sequence[SupportsFloat], start_idx: SupportsInt = 0, pt: bool = True) float
Parameters:
  • X (double) – Pressure/Volume

  • T (double) – Temperature

  • n (list) – Composition

  • start_idx (int) – Index of n[0], default is 0

  • pt (bool) – Calculate PT-based (true) or VT-based (false) property

Returns:

Mass density of mixture at (P,T,n)/(V,T,n)

Return type:

double

set_eos_ptrange(self: dartsflash.libflash.EoS, p_min: SupportsFloat = nan, p_max: SupportsFloat = nan, T_min: SupportsFloat = nan, T_max: SupportsFloat = nan) None

Specify PT-range for EoS

Parameters:
  • p_min (double) – Minimum pressure

  • p_max (double) – Maximum pressure

  • T_min (double) – Minimum pressure

  • T_max (double) – Maximum temperature

set_eos_range(self: dartsflash.libflash.EoS, i: SupportsInt, range: collections.abc.Sequence[SupportsFloat]) None

Specify composition range for EoS

Parameters:
  • i (int) – Component index

  • range (list) – Composition lower and upper bound

set_root_flag(self: dartsflash.libflash.EoS, root_flag: dartsflash.libflash.EoS.RootFlag) None
Parameters:

flag (EoS.RootFlag) – Root choice, -1/STABLE) lowest Gibbs energy, 0/MIN) minimum (L), 1/MAX) maximum (V); default is -1

volume_iterations(self: dartsflash.libflash.EoS, p: SupportsFloat, T: SupportsFloat, n: collections.abc.Sequence[SupportsFloat], start_idx: SupportsInt = 0, pt: bool = True) int
Parameters:
  • p (double) – Pressure

  • T (double) – Temperature

  • n (list) – Composition

  • start_idx (int) – Index of n[0], default is 0

  • pt (bool) – Calculate PT-based (true) or VT-based (false) property

Returns:

Number of iterations for volume solver at (P,T,n)

Return type:

int

HelmholtzEoS

class dartsflash.libflash.HelmholtzEoS

This is a base class for Helmholtz-based EoS.

For reference, see Michelsen and Mollerup (2007) - Thermodynamic Models: Fundamentals & Computational Aspects.

Cv(self: dartsflash.libflash.HelmholtzEoS, V: SupportsFloat, T: SupportsFloat, n: collections.abc.Sequence[SupportsFloat], start_idx: SupportsInt = 0, pt: bool = True) float
Parameters:
  • V (double) – Volume

  • T (double) – Temperature

  • n (list) – Composition

  • start_idx (int) – Index of n[0], default is 0

  • pt (bool) – Calculate PT-based (true) or VT-based (false) property

Returns:

Heat capacity at constant volume Cv of mixture at (P,T,n)/(V,T,n)

Return type:

double

JT(self: dartsflash.libflash.HelmholtzEoS, p: SupportsFloat, T: SupportsFloat, n: collections.abc.Sequence[SupportsFloat], start_idx: SupportsInt = 0, pt: bool = True) float
Parameters:
  • p (double) – Pressure

  • T (double) – Temperature

  • n (list) – Composition

  • start_idx (int) – Index of n[0], default is 0

  • pt (bool) – Calculate PT-based (true) or VT-based (false) property

Returns:

Joule-Thomson coefficient of mixture at (P,T,n)/(V,T,n)

Return type:

double

__init__(self: dartsflash.libflash.HelmholtzEoS, comp_data: CompData) None

This is the constructor of the HelmholtzEoS base class.

Parameters:

comp_data (CompData) – Component data

critical_point(self: dartsflash.libflash.HelmholtzEoS, n: collections.abc.Sequence[SupportsFloat]) HelmholtzEoS::CriticalPoint

Determine mixture critical point

Parameters:

n (list) – Composition

Returns:

HelmholtzEoS::CriticalPoint object

is_critical(self: dartsflash.libflash.HelmholtzEoS, X: SupportsFloat, T: SupportsFloat, n: collections.abc.Sequence[SupportsFloat], start_idx: SupportsInt = 0, pt: bool = True) bool

Determine if temperature is above or below critical temperature for mixture at (T,n) :param X: Pressure/Volume :type X: double :param T: Temperature :type T: double :param n: Composition :type n: list :param start_idx: Index of n[0], default is 0 :type start_idx: int :param pt: Calculate PT-based (true) or VT-based (false) property :type pt: bool

Returns:

Temperature is critical?

Return type:

bool

set_preferred_roots(self: dartsflash.libflash.HelmholtzEoS, i: SupportsInt, x: SupportsFloat, root_flag: dartsflash.libflash.EoS.RootFlag) None
Parameters:
  • i (int) – Component index

  • x (float) – Mole fraction of specified component

  • root_flag (EoS.RootFlag) – Root choice, 0/STABLE) lowest Gibbs energy, 1/MIN) minimum (L), 2/MAX) maximum (V); default is 0

vs(self: dartsflash.libflash.HelmholtzEoS, p: SupportsFloat, T: SupportsFloat, n: collections.abc.Sequence[SupportsFloat], start_idx: SupportsInt = 0, pt: bool = True) float
Parameters:
  • p (double) – Pressure

  • T (double) – Temperature

  • n (list) – Composition

  • start_idx (int) – Index of n[0], default is 0

  • pt (bool) – Calculate PT-based (true) or VT-based (false) property

Returns:

Sound speed vs in mixture at (P,T,n)/(V,T,n)

Return type:

double

class dartsflash.libflash.CubicEoS

This is a base class for cubic EoS.

For reference, see Michelsen and Mollerup (2007) - Thermodynamic Models: Fundamentals & Computational Aspects.

class CubicType

Predefined Cubic EoS

Members:

PR

SRK

PR = <CubicType.PR: 0>
SRK = <CubicType.SRK: 1>
__init__(self: dartsflash.libflash.CubicEoS.CubicType, value: SupportsInt) None
CubicEoS.CubicType.name -> str
property value
PR = <CubicType.PR: 0>
SRK = <CubicType.SRK: 1>
__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: dartsflash.libflash.CubicEoS, comp_data: CompData, cubic_type: CubicEoS::CubicType, volume_shift: bool = False) -> None

    This is the constructor of the HelmholtzEoS base class for predefined cubic parameters. The user can provide CubicEoS.PR or CubicEoS.SRK in the argument list.

    param comp_data:

    Component data

    type comp_data:

    CompData

    param cubic_type:

    Predefined cubic parameters, CubicEoS.PR (default) or CubicEoS.SRK

  2. __init__(self: dartsflash.libflash.CubicEoS, comp_data: CompData, cubic_params: CubicEoS::CubicParams) -> None

    This is the constructor of the HelmholtzEoS base class for user-defined cubic parameters. The user can provide a CubicEoS::CubicParams in the argument list.

    param comp_data:

    Component data

    type comp_data:

    CompData

    param cubic_params:

    User-defined cubic parameters

calc_coefficients(self: dartsflash.libflash.CubicEoS, p: SupportsFloat, T: SupportsFloat, n: collections.abc.Sequence[SupportsFloat], start_idx: SupportsInt = 0, pt: bool = True) list[float]
Parameters:
  • p (double) – Pressure

  • T (double) – Temperature

  • n (list) – Composition

Returns:

Coefficients of cubic polynomial for mixture at (P,T,n)

Return type:

list

AQ

class dartsflash.libflash.Ziabakhsh2012

This class evaluates Ziabakhsh and Kooi (2012) aqueous phase fugacity-activity model.

__init__(self: dartsflash.libflash.Ziabakhsh2012, comp_data: CompData) None
Parameters:

comp_data (CompData) – Component data

class dartsflash.libflash.Jager2003

This class evaluates Jager (2003) aqueous phase fugacity model.

__init__(self: dartsflash.libflash.Jager2003, comp_data: CompData) None
Parameters:

comp_data (CompData) – Component data

VdWP EoS

class dartsflash.libflash.VdWP

This is a base class for hydrate Van der Waals-Platteeuw (1959) type EoS.

class HydrateType

Type of hydrate

Members:

sI

sII

sH

__init__(self: dartsflash.libflash.VdWP.HydrateType, value: SupportsInt) None
VdWP.HydrateType.name -> str
sH = <HydrateType.sH: 2>
sI = <HydrateType.sI: 0>
sII = <HydrateType.sII: 1>
property value
__init__(self: dartsflash.libflash.VdWP, comp_data: CompData, hydrate_type: VdWP::HydrateType) None
Parameters:
  • comp_data (CompData) – Component data

  • hydrate_type (VdWP::HydrateType) – Hydrate type (sI, sII, sH)

fw(self: dartsflash.libflash.VdWP, p: SupportsFloat, T: SupportsFloat, f0: collections.abc.Sequence[SupportsFloat]) float
Parameters:
  • p (double) – Pressure

  • T (double) – Temperature

  • f0 (list) – List of fugacities of guest molecules

Returns:

Fugacity of water in hydrate phase at (P,T,f0)

Return type:

double

sH = <HydrateType.sH: 2>
sI = <HydrateType.sI: 0>
sII = <HydrateType.sII: 1>
xH(self: dartsflash.libflash.VdWP) list[float]
Returns:

Hydrate composition at equilibrium at (P,T,f0)

Return type:

list

class dartsflash.libflash.Ballard

This class evaluates the Ballard (2002) implementation of VdWP EoS.

__init__(self: dartsflash.libflash.Ballard, comp_data: CompData, hydrate_type: dartsflash.libflash.VdWP.HydrateType) None
Parameters:
  • comp_data (CompData) – Component data

  • hydrate_type (VdWP::HydrateType) – Hydrate type (sI, sII, sH)

PureSolid

class dartsflash.libflash.PureSolid

This class evaluates the Ballard (2002) implementation of a pure solid EoS.

CaCl2 = <SolidType.CaCl2: 2>
Ice = <SolidType.Ice: 0>
KCl = <SolidType.KCl: 3>
NaCl = <SolidType.NaCl: 1>
class SolidType

Type of solid

Members:

Ice

NaCl

CaCl2

KCl

CaCl2 = <SolidType.CaCl2: 2>
Ice = <SolidType.Ice: 0>
KCl = <SolidType.KCl: 3>
NaCl = <SolidType.NaCl: 1>
__init__(self: dartsflash.libflash.PureSolid.SolidType, value: SupportsInt) None
PureSolid.SolidType.name -> str
property value
__init__(self: dartsflash.libflash.PureSolid, comp_data: CompData, phase_type: PureSolid::SolidType) None
Parameters:
  • comp_data (CompData) – Component data

  • phase_type (SolidType) – Solid phase type

dartsflash

EoS Properties

Components

class dartsflash.components.CompData(components: list, salt_components: list = None, setprops: bool = True)[source]

Bases: CompData

This class contains component properties and data.

Variables:
  • nc – Number of components

  • nsalt – Number of salt components

  • ni – Number of ions

  • ns – Number of primary species (components + salts)

  • water_index – Index of H2O component

  • Pc – List of component critical pressures [bar]

  • Tc – List of component critical temperatures [K]

  • ac – List of component acentric factors [-]

  • Mw – List of species molar weight [g/mol]

  • kij – List of component binary interaction coefficients (flattened 2D array)

  • cpi – List of component ideal gas heat capacities

  • H0 – List of component H0 (Sander, 2006)

  • dlnH0 – List of component dlnH0 (Sander, 2006)

  • charge – List of ion charges

__init__(components: list, salt_components: list = None, setprops: bool = True)[source]
Parameters:
  • components (list) – List of components

  • salt_components (list) – List of salt components, default is None, sets empty list

  • setprops (bool) – Switch to get properties from pre-defined data, default is True

  • units (dartsflash.libflash.Units) – Object that contains units and methods for unit conversion

set_properties()[source]

Function to populate properties with pre-defined properties from data at the top of this file

dartsflash.components.get_properties(property: dict, species: list)[source]

Diagram

class dartsflash.diagram.Diagram(nrows: int = 1, ncols: int = 1, figsize: tuple = (8, 6), sharex: bool = False, sharey: bool = False)[source]

Bases: object

This is a base class for construction of diagrams.

Variables:
  • colours – Predefined set of colours

  • markers – Predefined set of markers

  • linestyles – Predefined set of linestyles

  • ax_labels – Axis labels

__init__(nrows: int = 1, ncols: int = 1, figsize: tuple = (8, 6), sharex: bool = False, sharey: bool = False)[source]

Constructor for Diagram base class

Parameters:
  • ncols (nrows,) – Number of rows/columns for subplots

  • figsize (tuple[float]) – Size of figure object

  • sharey (sharex,) – Share axes

add_attributes(subplot_idx: int = None, suptitle: str = None, title: str = None, ax_labels: list = None, legend: bool = False, legend_loc: str = 'upper right', grid: bool = False)[source]

Function to add attributes to diagram.

Parameters:
  • subplot_idx – Index of subplot to add attribute to, default is None which will apply it to all subplots

  • title (str) – Figure title

  • ax_labels (list[str]) – Axes labels

  • legend (bool) – Switch to add legend for lines/points

add_text(text: str, xloc: float, yloc: float, fontsize: float = 8, colours: str = 'k', box_colour: str = 'none')[source]

Function to add text to diagram.

cmap = 'winter'
colours = ['blue', 'lightskyblue', 'mediumseagreen', 'orchid', 'dodgerblue', 'darkcyan']
draw_contours(x, y, data: ndarray, mask: float = None, colours: str = None, linewidth: float = 1.0)[source]

Function to draw contour lines between discrete levels

Parameters:
  • x (list) – Grid points on x-axis

  • y (list) – Grid points on y-axis

  • datanp.ndarray of data for plotting

  • colours (str) – Colours for contourlines

  • linewidth (float) – Line width

draw_line(X: ndarray, Y: ndarray, colours: list = None, styles: list = None, widths: float = 2, datalabels: list = None)[source]

Function to draw line with coordinates X-Y(-Z)

Parameters:
  • Y (X,) – x- and y-axis values. N-D arrays must be provided as [ith_curve, values]

  • colours – Colour or list of colours

  • styles – Line-/Markerstyle or list of styles for line/scatter plot

  • widths – Line-/Markerwidth or list of widths for line/scatter plot

  • datalabels – List of datalabels

draw_point(X: ndarray, Y: ndarray, Z: ndarray = None, colours: list = None, markers: list = None, widths: list = None, datalabels: list = None)[source]

Function to draw points with coordinates X-Y(-Z)

Parameters:
  • X – List of X-coordinates for points

  • Y – List of Y-coordinates for points

  • Z – List of Z-coordinates for points, optional

  • colours – Colour or list of colours

  • styles – Markerstyle or list of styles for scatter plot

  • widths – Markerwidth or list of widths for scatter plot

  • datalabels – List of data labels

draw_surf(x, y, data: ndarray, xlim: list = None, ylim: list = None, ax_labels: list = None, is_float: bool = True, nlevels: int = 10, min_val: float = None, max_val: float = None, colours: list = None, colorbar: bool = False, colorbar_labels: list = None, colorbar_title: str = None, contour: bool = False, fill_contour: bool = False, contour_linestyle: str = None, logx: bool = False, logy: bool = False)[source]

Function to draw 2D pcolormesh/contourplot.

Parameters:
  • x (list) – Grid points on x-axis

  • y (list) – Grid points on y-axis

  • datanp.ndarray of data for plotting

  • ylim (xlim,) – Limits for axes

  • ax_labels – Axis labels

  • is_float – Type of data is float/integer

  • nlevels (int) – Number of contour levels for legend

  • min_val (float) – Minimum value of contour levels

  • max_val (float) – Maximum value of contour levels

  • colours (list[str]) – Colours for ListedColormap

  • colorbar (bool) – Switch to add colorbar

  • colorbar_labels – Optional labels for colorbar

  • colorbar_title (str) – Optional colorbar title

  • contour (bool) – Switch for contour or surface plot

  • fill_contour (bool) – Switch for filled contour plot

fontsizes = {'axes': 10, 'axlabel': 12, 'legend': 12, 'suptitle': 20, 'title': 16}
get_cmap(levels: ndarray, colours: list = None)[source]
get_contours(x, y, data: ndarray, mask: float = None)[source]
get_levels(data: ndarray, is_float: bool, nlevels: int, min_val: float = None, max_val: float = None)[source]
linestyles = ['solid', 'dashed', 'dotted', 'dashdot']
markers = [None, '--', 'o', 'v']
set_axes(xlim: list = None, ylim: list = None, logx: bool = False, logy: bool = False)[source]

Function to set axes limits and scale

Parameters:
  • ylim (xlim,) – Limits of x- and y-axes, default is None

  • logy (logx,) – Option to set x- or y-axis to logscale, default is False

class dartsflash.diagram.NCompDiagram(nc: int, dz: float, min_z: list = None, max_z: list = None, nrows: int = 1, ncols: int = 1, figsize: tuple = (10, 10))[source]

Bases: Diagram

This is a base class for construction of N-component diagrams.

__init__(nc: int, dz: float, min_z: list = None, max_z: list = None, nrows: int = 1, ncols: int = 1, figsize: tuple = (10, 10))[source]

The constructor will find the set of physical compositions.

Parameters:
  • nc (int) – Number of components

  • dz (float) – Mesh size of compositions

  • min_z (list[float]) – Minimum composition of each component (i = 1,…,nc-1), optional

  • max_z (list[float]) – Maximum composition of each component (i = 1,…,nc-1), optional

  • nrows (int) – Number of rows for subplots

  • ncols (int) – Number of columns for subplots

  • figsize (tuple[float]) – Size of figure object

class dartsflash.diagram.QuaternaryDiagram(dz, min_z: list = None, max_z: list = None, nrows: int = 1, ncols: int = 1, figsize: tuple = (10, 10))[source]

Bases: NCompDiagram

This class can construct quaternary diagrams.

__init__(dz, min_z: list = None, max_z: list = None, nrows: int = 1, ncols: int = 1, figsize: tuple = (10, 10))[source]

The constructor will find the set of physical compositions for nc=4.

Parameters:
  • dz (float) – Mesh size of compositions

  • min_z (list[float]) – Minimum composition of each component (i = 1,…,nc-1), optional

  • max_z (list[float]) – Maximum composition of each component (i = 1,…,nc-1), optional

  • nrows (int) – Number of rows for subplots

  • ncols (int) – Number of columns for subplots

  • figsize (tuple[float]) – Size of figure object

quaternary()[source]
class dartsflash.diagram.TernaryDiagram(dz: float, min_z: list = None, max_z: list = None, nrows: int = 1, ncols: int = 1, figsize: tuple = (10, 10))[source]

Bases: NCompDiagram

This class can construct ternary diagrams.

__init__(dz: float, min_z: list = None, max_z: list = None, nrows: int = 1, ncols: int = 1, figsize: tuple = (10, 10))[source]

The constructor will find the set of physical compositions for nc=3.

Parameters:
  • dz (float) – Mesh size of compositions

  • min_z (list[float]) – Minimum composition of each component (i = 1,…,nc-1), optional

  • max_z (list[float]) – Maximum composition of each component (i = 1,…,nc-1), optional

  • nrows (int) – Number of rows for subplots

  • ncols (int) – Number of columns for subplots

  • figsize (tuple[float]) – Size of figure object

draw_compositions(compositions: list, axes: list = None, colours: str = None, markerstyle: str = None, linestyle: str = None, connect_compositions: bool = False)[source]

Function to draw compositions in ternary plot.

Parameters:
  • compositions – Compositions of end points [[x0, y0, z0], [x1, y1, z1], …]

  • colours – Marker/line colour, optional

  • markerstyle – Point markerstyle, optional

  • linestyle – Linestyle, optional

  • connect_compositions – Switch to connect compositions with a line

draw_contours(X1, X2, data: ndarray, mask: float = None, xlim: list = None, ylim: list = None, corner_labels: list = None, colours: str = None, linewidth: float = 1.0)[source]

Function to draw contour lines between discrete levels

Parameters:
  • X1 (list) – Grid points on x-axis

  • X2 (list) – Grid points on y-axis

  • datanp.ndarray of data for plotting

  • colours (str) – Colours for contourlines

  • linewidth (float) – Line width

draw_surf(X1, X2, data: ndarray, corner_labels: list = None, xlim: list = None, ylim: list = None, is_float: bool = True, nlevels: int = 10, min_val: float = None, max_val: float = None, colours: list = None, colorbar: bool = False, colorbar_labels: list = None, colorbar_title: str = None, contour: bool = False, fill_contour: bool = False)[source]

Function to draw ternary pcolormesh/contourplot.

Parameters:
  • X2 (X1,) – Compositions of first and second components

  • datanp.ndarray of data for plotting

  • corner_labels – Labels of ternary diagram corners

  • ylim (xlim,) – Limits for axes

  • ax_labels – Axis labels

  • is_float – Type of data is float/integer

  • nlevels (int) – Number of contour levels for legend

  • min_val (float) – Minimum value of contour levels

  • max_val (float) – Maximum value of contour levels

  • colours (list[str]) – Colours for ListedColormap

  • colorbar (bool) – Switch to add colorbar

  • colorbar_labels – Labels for colorbar

  • colorbar_title (str) – Optional colorbar title

  • contour (bool) – Switch for contour or surface plot

  • fill_contour (bool) – Switch for filled contour plot

triangulation(X1: ndarray, X2: ndarray, corner_labels: list = None)[source]

Function to construct triangular grid and axis.

Parameters:
  • X2 (X1,) – Composition of 1st and second component

  • corner_labels – Labels at corners

Returns:

Triangular grid and Axes

Return type:

matplotlib.tri.Triangulation, matplotlib.pyplot.Axes