ChemKED¶
Main ChemKED module
- class pyked.chemked.Apparatus(kind: str | None, institution: str | None, facility: str | None)[source]¶
Information about the experimental apparatus used to generate the data
- class pyked.chemked.ChemKED(yaml_file=None, dict_input=None, *, skip_validation=False)[source]¶
Main ChemKED class.
The ChemKED class stores information about the contents of a ChemKED database file. It stores each datapoint associated with the database and provides access the the reference information, versions, and file author.
- Parameters:
yaml_file (
str, optional) – The filename of the YAML database in ChemKED format.dict_input (
dict, optional) – A dictionary with the parsed ouput of YAML file in ChemKED format.skip_validation (
bool, optional) – Whether validation of the ChemKED should be done. Must be supplied as a keyword-argument.
- reference¶
Attributes include
volume,journal,doi,authors,detail,year, andpagesdescribing the reference from which the datapoints are derived.- Type:
- apparatus¶
Attributes include
kindof experimental apparatus, and theinstitutionandfacilitywhere the experimental apparatus is located.- Type:
- _properties¶
Original dictionary read from ChemKED database file, meant for internal use.
- Type:
- convert_to_ReSpecTh(filename)[source]¶
Convert ChemKED record to ReSpecTh XML file.
This converter uses common information in a ChemKED file to generate a ReSpecTh XML file. Note that some information may be lost, as ChemKED stores some additional attributes.
- Parameters:
filename (
str) – Filename for output ReSpecTh XML file.
Example
>>> dataset = ChemKED(yaml_file) >>> dataset.convert_to_ReSpecTh(xml_file)
- classmethod from_respecth(filename_xml, file_author='', file_author_orcid='')[source]¶
Construct a ChemKED instance directly from a ReSpecTh file.
- Parameters:
- Returns:
Instance of the
ChemKEDclass containing the data infilename_xml.- Return type:
Examples
>>> ck = ChemKED.from_respecth('respecth_file.xml') >>> ck = ChemKED.from_respecth('respecth_file.xml', file_author='Bryan W. Weber') >>> ck = ChemKED.from_respecth('respecth_file.xml', file_author='Bryan W. Weber', file_author_orcid='0000-0000-0000-0000')
- get_dataframe(output_columns=None)[source]¶
Get a Pandas DataFrame of the datapoints in this instance.
- Parameters:
output_columns (
list, optional) –List of strings specifying the columns to include in the output DataFrame. The default is
None, which outputs all of the columns. Options include (not case sensitive):TemperaturePressureIgnition DelayCompositionEquivalence RatioReferenceApparatusExperiment TypeFile AuthorFile VersionChemKED Version
In addition, specific fields from the
ReferenceandApparatusattributes can be included by specifying the name after a colon. These options are:Reference:VolumeReference:JournalReference:DOIReference:AuthorsReference:DetailReference:YearReference:PagesApparatus:KindApparatus:FacilityApparatus:Institution
Only the first author is printed when
ReferenceorReference:Authorsis selected because the whole author list may be quite long.
Note
If the Composition is selected as an output type, the composition specified in the
DataPointis used. No attempt is made to convert to a consistent basis; mole fractions will remain mole fractions, mass fractions will remain mass fractions, and mole percent will remain mole percent. Therefore, it is possible to end up with more than one type of composition specification in a given column. However, if the composition is included in the resulting dataframe, the type of each composition will be specified by the “Kind” field in each row.Examples
>>> df = ChemKED(yaml_file).get_dataframe() >>> df = ChemKED(yaml_file).get_dataframe(['Temperature', 'Ignition Delay'])
- Returns:
- Contains the information regarding each point in the
datapoints attribute
- Contains the information regarding each point in the
- Return type:
- validate_yaml(properties)[source]¶
Validate the parsed YAML file for adherance to the ChemKED format.
- Parameters:
properties (
dict) – Dictionary created from the parsed YAML file- Raises:
ValueError – If the YAML file cannot be validated, a
ValueErroris raised whose string contains the errors that are present.
- class pyked.chemked.Composition(species_name: str, InChI: str | None, SMILES: str | None, atomic_composition: dict | None, amount: Quantity)[source]¶
Detail of the initial composition of the mixture for the experiment
- class pyked.chemked.DataPoint(properties)[source]¶
Class for a single datapoint.
The
DataPointclass stores the information associated with a single data point in the dataset parsed from theChemKEDYAML input.- Parameters:
properties (
dict) – Dictionary adhering to the ChemKED format fordatapoints
- ignition_delay¶
The ignition delay of the experiment
- Type:
- temperature¶
The temperature of the experiment
- Type:
- pressure¶
The pressure of the experiment
- Type:
- pressure_rise¶
The amount of pressure rise during the induction period of a shock tube experiment.
- Type:
pint.Quantity, optional
- compression_time¶
The compression time for an RCM experiment.
- Type:
pint.Quantity, optional
- compressed_pressure¶
The pressure at the end of compression for an RCM experiment.
- Type:
pint.Quantity, optional
- compressed_temperature¶
The temperature at the end of compression for an RCM experiment.
- Type:
pint.Quantity, optional
- first_stage_ignition_delay¶
The first stage ignition delay of the experiment.
- Type:
pint.Quantity, optional
- volume_history¶
The volume history of the reactor during an RCM experiment.
- Type:
namedtuple, optional
- pressure_history¶
The pressure history of the reactor during an experiment.
- Type:
namedtuple, optional
- temperature_history¶
The temperature history of the reactor during an experiment.
- Type:
namedtuple, optional
- piston_position_history¶
The piston position history of the reactor during an RCM experiment.
- Type:
namedtuple, optional
- light_emission_history¶
The light emission history of the reactor during an experiment.
- Type:
namedtuple, optional
- OH_emission_history¶
The OH emission history of the reactor during an experiment.
- Type:
namedtuple, optional
- absorption_history¶
The absorption history of the reactor during an experiment.
- Type:
namedtuple, optional
- get_cantera_composition_string(species_conversion=None)[source]¶
Get the composition in a string format suitable for input to Cantera.
Returns a formatted string no matter the type of composition. As such, this method is not recommended for end users; instead, prefer the
get_cantera_mole_fractionorget_cantera_mass_fractionmethods.- Parameters:
species_conversion (
dict, optional) – Mapping of species identifier to a species name. This argument should be supplied when the name of the species in the ChemKED YAML file does not match the name of the same species in a chemical kinetic mechanism. The species identifier (the key of the mapping) can be the name, InChI, or SMILES provided in the ChemKED file, while the value associated with a key should be the desired name in the Cantera format output string.- Returns:
String in the
SPEC:AMT, SPEC:AMTformat- Return type:
- Raises:
ValueError – If the composition type of the
DataPointis not one of'mass fraction','mole fraction', or'mole percent'
- get_cantera_mass_fraction(species_conversion=None)[source]¶
Get the mass fractions in a string format suitable for input to Cantera.
- Parameters:
species_conversion (
dict, optional) – Mapping of species identifier to a species name. This argument should be supplied when the name of the species in the ChemKED YAML file does not match the name of the same species in a chemical kinetic mechanism. The species identifier (the key of the mapping) can be the name, InChI, or SMILES provided in the ChemKED file, while the value associated with a key should be the desired name in the Cantera format output string.- Returns:
String of mass fractions in the
SPEC:AMT, SPEC:AMTformat- Return type:
- Raises:
ValueError – If the composition type is
'mole fraction'or'mole percent', the conversion cannot be done because no molecular weight information is known
Examples
>>> dp = DataPoint(properties) >>> dp.get_cantera_mass_fraction() 'H2:2.2525e-04, O2:4.4775e-03, Ar:9.9530e-01' >>> species_conversion = {'H2': 'h2', 'O2': 'o2'} >>> dp.get_cantera_mass_fraction(species_conversion) 'h2:2.2525e-04, o2:4.4775e-03, Ar:9.9530e-01' >>> species_conversion = {'1S/H2/h1H': 'h2', '1S/O2/c1-2': 'o2'} >>> dp.get_cantera_mass_fraction(species_conversion) 'h2:2.2525e-04, o2:4.4775e-03, Ar:9.9530e-01'
- get_cantera_mole_fraction(species_conversion=None)[source]¶
Get the mole fractions in a string format suitable for input to Cantera.
- Parameters:
species_conversion (
dict, optional) – Mapping of species identifier to a species name. This argument should be supplied when the name of the species in the ChemKED YAML file does not match the name of the same species in a chemical kinetic mechanism. The species identifier (the key of the mapping) can be the name, InChI, or SMILES provided in the ChemKED file, while the value associated with a key should be the desired name in the Cantera format output string.- Returns:
String of mole fractions in the
SPEC:AMT, SPEC:AMTformat- Return type:
- Raises:
ValueError – If the composition type is
'mass fraction', the conversion cannot be done because no molecular weight information is known
Examples
>>> dp = DataPoint(properties) >>> dp.get_cantera_mole_fraction() 'H2:4.4400e-03, O2:5.5600e-03, Ar:9.9000e-01' >>> species_conversion = {'H2': 'h2', 'O2': 'o2'} >>> dp.get_cantera_mole_fraction(species_conversion) 'h2:4.4400e-03, o2:5.5600e-03, Ar:9.9000e-01' >>> species_conversion = {'1S/H2/h1H': 'h2', '1S/O2/c1-2': 'o2'} >>> dp.get_cantera_mole_fraction(species_conversion) 'h2:4.4400e-03, o2:5.5600e-03, Ar:9.9000e-01'
- class pyked.chemked.RCMData(compressed_pressure: Quantity | None, compressed_temperature: Quantity | None, compression_time: Quantity | None, stroke: Quantity | None, clearance: Quantity | None, compression_ratio: Quantity | None)[source]¶
Data fields specific to rapid compression machine experiments
- class pyked.chemked.Reference(volume: str | None, journal: str | None, doi: str | None, authors: list | None, detail: str | None, year: int | None, pages: str | None)[source]¶
Information about the article or report where the data can be found