Module “system”¶
- class tc_python.system.MultiDatabaseSystemBuilder(multi_database_system_builder)¶
Bases:
object
Used to select databases, elements, phases etc. and create a System object. The difference to the class SystemBuilder is that the operations are performed on all the previously selected databases. The system is then used to create calculations.
- create_and_select_species(stoichiometry: str)¶
Specify a species from the already entered elements. The stoichiometry of the species is the chemical formula of the species. The created species will also be automatically selected.
Note
The elements in the chemical formula are normally separated by stoichiometric numbers. Neither parenthesis “()” nor an underscore “_” is allowed in the chemical formula, while the special combination “/-“ or “/+” can be used. Consult the Thermo-Calc database documentation for details about the syntax.
- Parameters
stoichiometry – The stoichiometry of the species
- Returns
This
MultiDatabaseSystemBuilder
object
- deselect_constituent_on_sublattice(phase_name: str, sublattice_no: int, constituent_name_to_deselect: str)¶
Rejects a constituent on a sublattice in a phase in both the thermodynamic and the kinetic database.
- Parameters
phase_name – The name of the phase
sublattice_no – The number of the sublattice (starting with 1)
constituent_name_to_deselect – The name of the constituent to deselect
- Returns
This
MultiDatabaseSystemBuilder
object
- deselect_phase(phase_name_to_deselect: str)¶
Rejects a phase for both the thermodynamic and the kinetic database.
- Parameters
phase_name_to_deselect – The phase name
- Returns
This
MultiDatabaseSystemBuilder
object
- deselect_species(species_name: str)¶
Removes the species from the system.
- Parameters
species_name – The species
- Returns
This
MultiDatabaseSystemBuilder
object
- get_system() System ¶
Creates a new System object that is the basis for all calculation types. Several calculation types can be defined later from the object; these are independent.
- Returns
A new
System
object
- select_constituent_on_sublattice(phase_name: str, sublattice_no: int, constituent_name_to_select: str)¶
Selects a constituent on a sublattice in a phase in both the thermodynamic and the kinetic database.
Note
Previously the third parameter constituent_name_to_select had a wrong name, it has been corrected in version 2021b.
- Parameters
phase_name – The name of the phase
sublattice_no – The number of the sublattice (starting with 1)
constituent_name_to_select – The name of the constituent to select
- Returns
This
MultiDatabaseSystemBuilder
object
- select_phase(phase_name_to_select: str)¶
Selects a phase for both the thermodynamic and the kinetic database.
- Parameters
phase_name_to_select – The phase name
- Returns
This
MultiDatabaseSystemBuilder
object
- select_species(species_name: str)¶
Adds the species to the system. Up to 1000 species can be defined in a single system.
- Parameters
species_name – The species
- Returns
This
MultiDatabaseSystemBuilder
object
- with_new_composition_set(composition_set: CompositionSet)¶
Used to enter two or more composition sets for a phase. If a phase has a miscibility gap it is necessary to have two composition sets, one for each possible composition that can be stable simultaneously.
The databases often create the typical composition sets for phases automatically when data are retrieved. The equilibrium calculations (using the default settings with global minimization) will usually add new composition sets if needed.
Note
Precipitation and diffusion calculations can require the user to define additional composition sets. E.g. in the case where the new composition set is needed in the configuration of the calculation.
- Parameters
composition_set – the composition set
- Returns
This
MultiDatabaseSystemBuilder
object
- without_default_phases()¶
Rejects all the default phases from both the thermodynamic and the kinetic database, any phase now needs to be selected manually for the databases.
- Returns
This
MultiDatabaseSystemBuilder
object
- class tc_python.system.System(system_instance)¶
Bases:
object
A system containing selections for databases, elements, phases etc.
Note
For the defined system, different calculations can be configured and run. Instances of this class should always be created from a SystemBuilder.
Note
The system object is immutable, i.e. it cannot be changed after is has been created. If you want to change the system, you must instead create a new one.
- convert_composition(input_composition: Dict[str, float], input_unit: ConversionUnit, output_unit: ConversionUnit, dependent_component: str = '') Dict[str, float] ¶
Provides conversion between composition units for any combination of chemical compounds. It is fast because no thermodynamic equilibrium calculation is involved.
Syntax of the chemical compounds: “Al2O3”, “FeO”, “CO”, “Fe”, “C”, …
Note
It is not required that the chemical compounds are components of the database. The only requirement is that all elements are present in the database.
- Parameters
input_composition – Composition (for example: {“Al2O3”: 25.0, “FeO”: 75.0})
input_unit – Unit of the input composition
output_unit – Requested output unit
dependent_component – The dependent component (optional), for example: “Fe”. If no dependent component is specified the sum of the input composition needs to match 100% / 1
- Returns
The composition in the requested output unit
- get_all_elements_in_databases() List[str] ¶
Returns the names of all elements present in the selected databases, regardless of the actual selection of elements.
- Returns
A list of element names
- get_all_phases_in_databases() List[str] ¶
Returns all phase names present in the selected databases, regardless of selected elements, phases etc.
- Returns
A list of phase names
- get_all_species_in_databases() List[str] ¶
Returns all species names present in the selected databases, regardless of the actual selection of elements, phases, ….
- Returns
A list of species names
- get_element_object(element_name: str) Element ¶
Returns the
Element
object of an element. This can be used to obtain detailed information about the element.- Parameters
element_name – The element name
- Returns
A
Element
: object
- get_elements_in_system() List[str] ¶
Returns the names of all elements present in the selected system.
Note
The list does not contain any elements or components that have been auto-selected by the database(s) in a calculator. Use the
get_components()
of the calculator object instead to get the complete information.- Returns
A list of element names
- get_phase_object(phase_name: str) Phase ¶
Returns the
Phase
object of a phase. This can be used to obtain detailed information about the phase.- Parameters
phase_name – The phase name
- Returns
A
Phase
: object
- get_phases_in_system() List[str] ¶
Returns all phase names present in the system due to its configuration (selected elements, phases, etc.).
- Returns
A list of phase names
- get_references() Dict[str, List[str]] ¶
Provides a dictionary with database references per database in the selected system.
- Returns
The database references
- get_species_in_system() List[str] ¶
Returns the names of all species present in the selected system.
Note
The list does not contain any species or components that have been auto-selected by the database(s) in a calculator. Use the
get_components()
of the calculator object instead to get the complete information.- Returns
The list of species names
- get_species_object(species_name: str) Species ¶
Returns the
Species
object of an species. This can be used to obtain detailed information about the species.- Parameters
species_name – The species name
- Returns
A
Species
: object
- get_system_data() SystemData ¶
Returns the content of the database. This can be used to modify the parameters and functions and to change the current system by using
with_system_modifications()
.Note
Parameters can only be read from unencrypted (i.e. user) databases loaded as *.tdb-file.
- Returns
The system data
- with_batch_equilibrium_calculation(default_conditions: bool = True, components: List[str] = []) BatchEquilibriumCalculation ¶
Creates a batch-equilibrium calculation (a vectorized equilibrium calculation).
Note
Use this instead of looping if you want to calculate equilibria for a larger number of compositions and know the conditions in advance. This calculation type has improved performance when calculating a large number of equilibria when each individual calculations is quick. E.g. when evaluating single phase properties for thousands of compositions.
- Parameters
default_conditions – If True, automatically sets the conditions N=1 and P=100000
components – Specify here the components of the system (for example: [AL2O3, …]), only necessary if they differ from the elements. If this option is used, all elements of the system need to be replaced by a component.
- Returns
A new
BatchEquilibriumCalculation
object
- with_cct_precipitation_calculation() PrecipitationCCTCalculation ¶
Creates a CCT diagram calculation.
- Returns
A new
PrecipitationCCTCalculation
object
- with_isothermal_diffusion_calculation() DiffusionIsoThermalCalculation ¶
Creates an isothermal diffusion calculation.
- Returns
A new
DiffusionIsoThermalCalculation
object
- with_isothermal_precipitation_calculation() PrecipitationIsoThermalCalculation ¶
Creates an isothermal precipitation calculation.
- Returns
A new
PrecipitationIsoThermalCalculation
object
- with_material_to_material() MaterialToMaterialCalculationContainer ¶
Provides access to all Material to Material calculations. The actual calculation needs to be chosen in the returned object.
- Returns
A new
MaterialToMaterialCalculationContainer
object
- with_non_isothermal_diffusion_calculation() DiffusionNonIsoThermalCalculation ¶
Creates a non-isothermal precipitation calculation.
- Returns
A new
PrecipitationNonIsoThermalCalculation
object
- with_non_isothermal_precipitation_calculation() PrecipitationNonIsoThermalCalculation ¶
Creates a non-isothermal precipitation calculation.
- Returns
A new
PrecipitationNonIsoThermalCalculation
object
- with_phase_diagram_calculation(default_conditions: bool = True, components: List[str] = []) PhaseDiagramCalculation ¶
Creates a phase diagram (map) calculation.
- Parameters
default_conditions – If True, automatically sets the conditions N=1 and P=100000
components – Specify here the components of the system (for example: [AL2O3, …]), only necessary if they differ from the elements. If this option is used, all elements of the system need to be replaced by a component.
- Returns
A new
PhaseDiagramCalculation
object
- with_property_diagram_calculation(default_conditions: bool = True, components: List[str] = []) PropertyDiagramCalculation ¶
Creates a property diagram (step) calculation.
- Parameters
default_conditions – If True, automatically sets the conditions N=1 and P=100000
components – Specify here the components of the system (for example: [AL2O3, …]), only necessary if they differ from the elements. If this option is used, all elements of the system need to be replaced by a component.
- Returns
A new
PropertyDiagramCalculation
object
- with_property_model_calculation(model: str, path_to_models: str = '', debug_model: bool = False) PropertyModelCalculation ¶
Creates a Property Model calculation.
The parameter debug_model is only used when debugging self-developed models.
- Parameters
model – The Property Model to be calculated.
path_to_models – The path where the Property Models are installed. If no value is entered, the Property Models folder used by the normal Thermo-Calc application is used.
debug_model – Used when debugging self-developed models.
- Returns
A new
PropertyModelCalculation
object
- with_scheil_calculation() ScheilCalculation ¶
Creates a Scheil solidification calculation.
Warning
Scheil calculations do not support the GAS phase being selected, this means the `GAS` phase must always be deselected in the system if it is present in the database
- Returns
A new
ScheilCalculation
object
- with_single_equilibrium_calculation(default_conditions: bool = True, components: List[str] = []) SingleEquilibriumCalculation ¶
Creates a single equilibrium calculation.
- Parameters
default_conditions – If True, automatically sets the conditions N=1 and P=100000
components – Specify here the components of the system (for example: [AL2O3, …]), only necessary if they differ from the elements. If this option is used, all elements of the system need to be replaced by a component.
- Returns
A new
SingleEquilibriumCalculation
object
- with_ttt_precipitation_calculation() PrecipitationTTTCalculation ¶
Creates a TTT diagram calculation.
- Returns
A new
PrecipitationTTTCalculation
object
- class tc_python.system.SystemBuilder(system_builder)¶
Bases:
object
Used to select databases, elements, phases etc. and create a System object. The system is then used to create calculations.
- create_and_select_species(stoichiometry: str)¶
Specify a species from the already entered elements. The stoichiometry of the species is the chemical formula of the species. The created species will also be automatically selected.
Note
The elements in the chemical formula are normally separated by stoichiometric numbers. Neither parenthesis “()” nor an underscore “_” is allowed in the chemical formula, while the special combination “/-“ or “/+” can be used. Consult the Thermo-Calc database documentation for details about the syntax.
- Parameters
stoichiometry – The stoichiometry of the species
- Returns
This
SystemBuilder
object
- deselect_constituent_on_sublattice(phase_name: str, sublattice_no: int, constituent_name_to_deselect: str)¶
Rejects a constituent on a sublattice in a phase in the last specified database only.
- Parameters
phase_name – The name of the phase
sublattice_no – The number of the sublattice (starting with 1)
constituent_name_to_deselect – The name of the constituent to deselect
- Returns
This
SystemBuilder
object
- deselect_phase(phase_name_to_deselect: str)¶
Rejects a phase in the last specified database only.
- Parameters
phase_name_to_deselect – The name of the phase
- Returns
This
SystemBuilder
object
- deselect_species(stoichiometry: str)¶
Removes the species from the system.
- Parameters
stoichiometry – The species
- Returns
This
SystemBuilder
object
- get_system() System ¶
Creates a new System object that is the basis for all calculation types. Several calculation types can be defined later from the object; these are independent.
- Returns
A new
System
object
- get_system_for_scheil_calculations() System ¶
Creates a new System object without gas phases being selected, that is the basis for all calculation types, but its particularly useful for Scheil solidification calculations, where the model does not allow that a gas phase is selected in the system.
Several calculation types can be defined later from the object; these are independent.
Note
Deprecated in version 2022b: Use
get_system()
instead. There are no longer any special requirements from the Thermo-Calc program to deselect the gas phase for Scheil. It will be removed in release 2023b.- Returns
A new
System
object
- select_constituent_on_sublattice(phase_name: str, sublattice_no: int, constituent_name_to_select: str)¶
Selects a constituent on a sublattice in a phase in the last specified database only.
Note
Previously the third parameter constituent_name_to_select had a wrong name, it has been corrected in version 2021b.
- Parameters
phase_name – The name of the phase
sublattice_no – The number of the sublattice (starting with 1)
constituent_name_to_select – The name of the constituent to select
- Returns
This
SystemBuilder
object
- select_database_and_elements(database_name: str, list_of_element_strings: List[str])¶
Selects a thermodynamic or kinetic database and its selected elements (that will be appended). After that, phases can be selected or unselected.
- Parameters
database_name – The database name, for example “FEDEMO”
list_of_element_strings – A list of one or more elements as strings, for example [“Fe”, “C”]
- Returns
This
SystemBuilder
object
- select_phase(phase_name_to_select: str)¶
Selects a phase in the last specified database only.
- Parameters
phase_name_to_select – The name of the phase
- Returns
This
SystemBuilder
object
- select_species(stoichiometry: str)¶
Adds the species to the system. Up to 1000 species can be defined in a single system.
- Parameters
stoichiometry – The species
- Returns
This
SystemBuilder
object
- select_user_database_and_elements(path_to_user_database: str, list_of_element_strings: List[str])¶
Selects a thermodynamic database which is a user-defined database and select its elements (that will be appended).
Note
By using a r-literal, it is possible to use slashes on all platforms, also on Windows: select_user_database_and_elements(r”my path/user_db.tdb”, [“Fe”, “Cr”]])
Otherwise it is required to use double back-slashes on Windows as separator.
Note
On Linux and Mac the path is case-sensitive, also the file ending.
- Parameters
path_to_user_database – The path to the database file (“database”.TDB), defaults to the current working directory. Only the filename is required if the database is located in the same folder as the script.
list_of_element_strings – A list of one or more elements as strings, for example [“Fe”, “C”]
- Returns
This
SystemBuilder
object
- with_new_composition_set(composition_set: CompositionSet)¶
Used to enter composition sets for a phase. If a phase has a miscibility gap it is necessary to have two composition sets, one for each possible composition that can be stable simultaneously.
- Parameters
composition_set – The composition set
- Returns
This
SystemBuilder
object
- without_default_phases()¶
Rejects all default phases in the last specified database only, any phase needs now to be selected manually for that database.
- Returns
This
SystemBuilder
object