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.
Ignition delay and speciation measurement files can be converted. A speciation measurement is written as whichever of the four ReSpecTh speciation types fits its apparatus and swept axis; see
_speciation_to_ReSpecTh.- 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, amount_esd: EvaluatedStandardDeviation | None = None)[source]¶
Detail of the initial composition of the mixture for the experiment
- amount_esd: EvaluatedStandardDeviation | None¶
(
EvaluatedStandardDeviation) The evaluated standard deviation of the amount, if specified
- 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
- laminar_burning_velocity¶
The laminar burning velocity 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
- evaluated_standard_deviation¶
Mapping of property name (with underscores, e.g.
ignition_delay) to theEvaluatedStandardDeviationgiven in the file for that property, for properties that specify one.- Type:
- 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'
- process_equivalence_ratio(properties)[source]¶
Process equivalence ratio while preserving the historic scalar API.
- process_evaluated_standard_deviation(properties)[source]¶
Extract evaluated-standard-deviation metadata from a quantity list.
- class pyked.chemked.EvaluatedStandardDeviation(value: Quantity | float, type: str | None, sourcetype: str | None, method: str | None)[source]¶
Evaluated standard deviation metadata attached to a quantity
- 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
- class pyked.chemked.TimeHistory(time: Quantity, quantity: Quantity, type: str)[source]¶
Time history of the quantity in an RCM experiment
- class pyked.chemked.VolumeHistory(time: Quantity, volume: Quantity)[source]¶
Time history of the volume in an RCM experiment. Deprecated, to be removed after PyKED 0.4
- pyked.chemked.concentration_kinds = {'mol/L', 'mol/cm3', 'mol/dm3', 'mol/m3'}¶
Composition kinds that are concentrations, which ReSpecTh names
concentrationrather thancomposition- Type:
- pyked.chemked.respecth_axis_names = {'distance': 'distance', 'equivalence-ratio': 'equivalence ratio', 'initial-composition': 'initial composition', 'pressure': 'pressure', 'residence-time': 'residence time', 'temperature': 'temperature', 'time': 'time'}¶
Speciation independent-variable name mapped to the ReSpecTh dataGroup property name, the inverse of
independent_variables- Type:
- pyked.chemked.respecth_labels = {'distance': 'x', 'equivalence ratio': 'phi', 'pressure': 'P', 'residence time': 'tau', 'temperature': 'T', 'time': 't', 'volume': 'V'}¶
ReSpecTh property name mapped to the column label ReSpecTh files give it
- Type:
- pyked.chemked.respecth_property_names = {'environment-temperature': 'environment temperature', 'equivalence-ratio': 'equivalence ratio', 'exchange-area': 'exchange area', 'flow-rate': 'flow rate', 'global-heat-exchange-coefficient': 'global heat exchange coefficient', 'ignition-delay': 'ignition delay', 'laminar-burning-velocity': 'laminar burning velocity', 'pressure': 'pressure', 'pressure-in-reference-state': 'pressure in reference state', 'pressure-rise': 'pressure rise', 'reactor-diameter': 'reactor diameter', 'reactor-length': 'reactor length', 'reactor-volume': 'volume', 'residence-time': 'residence time', 'temperature': 'temperature', 'temperature-in-reference-state': 'temperature in reference state', 'volumetric-flow-in-reference-state': 'volumetric flow rate in reference state'}¶
ChemKED field name mapped to the ReSpecTh property name, the inverse of
common_property_fields- Type:
- pyked.chemked.respecth_speciation_apparatus = {'burner stabilized flame': ('flame', ['burner-stabilized']), 'flow reactor': ('flow reactor', []), 'jet stirred reactor': ('jet stirred reactor', []), 'shock tube': ('shock tube', [])}¶
ChemKED
apparatus.kindof a speciation measurement mapped to the ReSpecThapparatus/kindandapparatus/modeelements- Type:
- pyked.chemked.row_uncertainty = {'bound': 'plusminus', 'kind': 'absolute', 'name': 'uncertainty', 'value': ''}¶
Descriptor of the uncertainty a ChemKED profile row ends with when nothing says otherwise, which is an absolute uncertainty in the units of the profile. Its values are in the rows, so it has none of its own.
- Type: