Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #12 #80

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Fixed

- Fixed bug in soln2ck.py where the reaction high rate was being used instead of the reaction low rate.
- Fixed issue #12 from git: made sure input species are included in target or retained species

## [1.1.0] - 2019-09-06

Expand Down
40 changes: 40 additions & 0 deletions ignition_data.dat

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions ignition_output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
1.066764602384077554e+00
3.055344172355624333e-02
7 changes: 7 additions & 0 deletions pymars/pymars.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,13 @@ def parse_inputs(input_dict):
psr_inputs = parse_psr_inputs(model, psr_conditions, phase_name)
flame_inputs = parse_flame_inputs(model, flame_conditions, phase_name)

# check all input species included in target or retained species
combined_species = target_species + safe_species
for case in ignition_conditions:
for inputs in list(case['fuel'].keys()) + list(case['oxidizer'].keys()):
if inputs not in combined_species:
safe_species.append(inputs)

return ReductionInputs(
model=model, error=error,
ignition_conditions=ignition_inputs,
Expand Down
45 changes: 45 additions & 0 deletions pymars/tests/assets/example1_input_file.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
model: gri30.cti
# List of target species
targets:
- CH4
- O2
# List of species to be always retained
retained-species:
- N2
# options: DRG, DRGEP, PFA
method: DRG
# Error limit, in percentage
error: 10.0

# Sensitivity analysis inputs
# True to enable sensitivity analysis
sensitivity-analysis: False
# options: initial, greedy
sensitivity-type: initial
upper-threshold: 0.2

autoignition-conditions:
- kind: constant volume
# units: atm
pressure: 1.0
# units: K
temperature: 1000
# species given in mole fractions
fuel:
CH4: 0.5
H2: 0.5
oxidizer:
O2: 1.0
N2: 3.76
equivalence-ratio: 1.0

- kind: constant volume
pressure: 1.0
temperature: 1200
end-time: 10.0
fuel:
CH4: 1.0
oxidizer:
O2: 1.0
N2: 3.76
equivalence-ratio: 0.5
46 changes: 46 additions & 0 deletions pymars/tests/assets/example2_input_file.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
model: gri30.cti
# List of target species
targets:
- CH4
- O2
# List of species to be always retained
retained-species:
- N2
# options: DRG, DRGEP, PFA
method: DRG
# Error limit, in percentage
error: 10.0

# Sensitivity analysis inputs
# True to enable sensitivity analysis
sensitivity-analysis: False
# options: initial, greedy
sensitivity-type: initial
upper-threshold: 0.2

autoignition-conditions:
- kind: constant volume
# units: atm
pressure: 1.0
# units: K
temperature: 1000
# species given in mole fractions
fuel:
CH4: 0.5
H2: 0.5
AR: 0.5
oxidizer:
O2: 1.0
N2: 3.76
equivalence-ratio: 1.0

- kind: constant volume
pressure: 1.0
temperature: 1200
end-time: 10.0
fuel:
CH4: 1.0
oxidizer:
O2: 1.0
N2: 3.76
equivalence-ratio: 0.5
46 changes: 46 additions & 0 deletions pymars/tests/assets/example3_input_file.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
model: gri30.cti
# List of target species
targets:
- CH4
- O2
# List of species to be always retained
retained-species:
- N2
# options: DRG, DRGEP, PFA
method: DRG
# Error limit, in percentage
error: 10.0

# Sensitivity analysis inputs
# True to enable sensitivity analysis
sensitivity-analysis: False
# options: initial, greedy
sensitivity-type: initial
upper-threshold: 0.2

autoignition-conditions:
- kind: constant volume
# units: atm
pressure: 1.0
# units: K
temperature: 1000
# species given in mole fractions
fuel:
CH4: 0.5
H2: 0.5
oxidizer:
O2: 1.0
N2: 3.76
AR: 1.0
equivalence-ratio: 1.0

- kind: constant volume
pressure: 1.0
temperature: 1200
end-time: 10.0
fuel:
CH4: 1.0
oxidizer:
O2: 1.0
N2: 3.76
equivalence-ratio: 0.5
46 changes: 46 additions & 0 deletions pymars/tests/assets/example4_input_file.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
model: gri30.cti
# List of target species
targets:
- CH4
- O2
# List of species to be always retained
retained-species:
- N2
# options: DRG, DRGEP, PFA
method: DRG
# Error limit, in percentage
error: 10.0

# Sensitivity analysis inputs
# True to enable sensitivity analysis
sensitivity-analysis: False
# options: initial, greedy
sensitivity-type: initial
upper-threshold: 0.2

autoignition-conditions:
- kind: constant volume
# units: atm
pressure: 1.0
# units: K
temperature: 1000
# species given in mole fractions
fuel:
CH4: 0.5
H2: 0.5
oxidizer:
O2: 1.0
N2: 3.76
equivalence-ratio: 1.0

- kind: constant volume
pressure: 1.0
temperature: 1200
end-time: 10.0
fuel:
CH4: 1.0
AR: 1.0
oxidizer:
O2: 1.0
N2: 3.76
equivalence-ratio: 0.5
46 changes: 46 additions & 0 deletions pymars/tests/assets/example5_input_file.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
model: gri30.cti
# List of target species
targets:
- CH4
- O2
# List of species to be always retained
retained-species:
- N2
# options: DRG, DRGEP, PFA
method: DRG
# Error limit, in percentage
error: 10.0

# Sensitivity analysis inputs
# True to enable sensitivity analysis
sensitivity-analysis: False
# options: initial, greedy
sensitivity-type: initial
upper-threshold: 0.2

autoignition-conditions:
- kind: constant volume
# units: atm
pressure: 1.0
# units: K
temperature: 1000
# species given in mole fractions
fuel:
CH4: 0.5
H2: 0.5
oxidizer:
O2: 1.0
N2: 3.76
equivalence-ratio: 1.0

- kind: constant volume
pressure: 1.0
temperature: 1200
end-time: 10.0
fuel:
CH4: 1.0
oxidizer:
O2: 1.0
N2: 3.76
AR: 1.0
equivalence-ratio: 0.5
47 changes: 47 additions & 0 deletions pymars/tests/test_pymars.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#tests to verify that various input species get included in retained or safe species

import os
import pkg_resources
import ruamel_yaml as yaml

from ..pymars import parse_inputs

def relative_location(file):
file_path = os.path.join(file)
return pkg_resources.resource_filename(__name__, file_path)


def test_species_check1():
input_file = relative_location(os.path.join('assets', 'example1_input_file.yaml'))
with open(input_file, 'r') as the_file:
input_dict = yaml.safe_load(the_file)
inputs = parse_inputs(input_dict)
assert 'H2' in inputs.safe_species

def test_species_check2():
input_file = relative_location(os.path.join('assets', 'example2_input_file.yaml'))
with open(input_file, 'r') as the_file:
input_dict = yaml.safe_load(the_file)
inputs = parse_inputs(input_dict)
assert 'AR' in inputs.safe_species

def test_species_check3():
input_file = relative_location(os.path.join('assets', 'example3_input_file.yaml'))
with open(input_file, 'r') as the_file:
input_dict = yaml.safe_load(the_file)
inputs = parse_inputs(input_dict)
assert 'AR' in inputs.safe_species

def test_species_check4():
input_file = relative_location(os.path.join('assets', 'example4_input_file.yaml'))
with open(input_file, 'r') as the_file:
input_dict = yaml.safe_load(the_file)
inputs = parse_inputs(input_dict)
assert 'AR' in inputs.safe_species

def test_species_check5():
input_file = relative_location(os.path.join('assets', 'example5_input_file.yaml'))
with open(input_file, 'r') as the_file:
input_dict = yaml.safe_load(the_file)
inputs = parse_inputs(input_dict)
assert 'AR' in inputs.safe_species