Skip to content

Commit

Permalink
handle uncertainties in properties
Browse files Browse the repository at this point in the history
  • Loading branch information
kyleniemeyer committed Feb 22, 2018
1 parent a79286c commit 1442f91
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Added

### Fixed
- Fixed ability to handle ChemKED files with uncertainty for various properties.

### Changed

Expand Down
2 changes: 1 addition & 1 deletion pyteck/_version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version_info__ = (0, 2, 3, '')
__version_info__ = (0, 2, 4, 'a1')
__version__ = '.'.join(map(str, __version_info__[:3]))
if len(__version_info__) == 4:
__version__ += __version_info__[-1]
14 changes: 11 additions & 3 deletions pyteck/eval_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,15 @@ def get_changing_variable(cases):
changing_var = 'temperature'

if changing_var == 'temperature':
variable = [case.temperature.magnitude for case in cases]
variable = [case.temperature.value.magnitude if hasattr(case.temperature, 'value')
else case.temperature.magnitude
for case in cases
]
elif changing_var == 'pressure':
variable = [case.pressure.magnitude for case in cases]
variable = [case.pressure.magnitude if hasattr(case.pressure, 'value')
else case.pressure.magnitude
for case in cases
]
return variable


Expand Down Expand Up @@ -266,7 +272,9 @@ def evaluate_model(model_name, spec_keys_file, dataset_file,
#############################################
# Determine standard deviation of the dataset
#############################################
ign_delay = [case.ignition_delay.to('second').magnitude
ign_delay = [case.ignition_delay.to('second').value.magnitude
if hasattr(case.ignition_delay, 'value')
else case.ignition_delay.to('second').magnitude
for case in properties.datapoints
]

Expand Down
20 changes: 16 additions & 4 deletions pyteck/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,16 +217,25 @@ def setup_case(self, model_file, species_key, path=''):
self.gas = ct.Solution(model_file)

# Convert ignition delay to seconds
self.properties.ignition_delay.ito('second')
if hasattr(self.properties.ignition_delay, 'value'):
self.properties.ignition_delay = self.properties.ignition_delay.to('second').value
else:
self.properties.ignition_delay.ito('second')

# Set end time of simulation to 100 times the experimental ignition delay
self.time_end = 100. * self.properties.ignition_delay.magnitude

# Initial temperature needed in Kelvin for Cantera
self.properties.temperature.ito('kelvin')
if hasattr(self.properties.temperature, 'value'):
self.properties.temperature = self.properties.temperature.to('kelvin').value
else:
self.properties.temperature.ito('kelvin')

# Initial pressure needed in Pa for Cantera
self.properties.pressure.ito('pascal')
if hasattr(self.properties.pressure, 'value'):
self.properties.pressure = self.properties.pressure.to('pascal').value
else:
self.properties.pressure.ito('pascal')

# convert reactant names to those needed for model
reactants = [species_key[spec['species-name']] + ':' + str(spec['amount'].magnitude)
Expand Down Expand Up @@ -262,7 +271,10 @@ def setup_case(self, model_file, species_key, path=''):
# Shock tube modeled by constant UV with isentropic compression

# Need to convert pressure rise units to seconds
self.properties.pressure_rise.ito('1 / second')
if hasattr(self.properties.pressure_rise, 'value'):
self.properties.pressure_rise = self.properties.pressure_rise.to('1 / second').value
else:
self.properties.pressure_rise.ito('1 / second')

self.wall = ct.Wall(self.reac, env, A=1.0,
velocity=PressureRiseProfile(
Expand Down

0 comments on commit 1442f91

Please sign in to comment.