Mercurial > hg > cfcfd3
changeset 2565:3805e549f120
app/pitot: found a bug with the csv output when a perfect gas driver is used
Turns out that I had made changes to the text file output to fix the issue,
but not the csv output. Rewrote the output for both the text and csv output
versions so that they are both a bit more better coded, and the csv one now
works for the perfect gas driver.
author | Chris James <c.james4@uq.edu.au> |
---|---|
date | Wed, 28 Feb 2018 12:50:06 +1000 |
parents | 52707e66fd24 |
children | ef8989d00f86 |
files | app/pitot/pitot.py app/pitot/pitot_input_utils.py app/pitot/pitot_output_utils.py |
diffstat | 3 files changed, 20 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- a/app/pitot/pitot.py Tue Feb 27 09:51:25 2018 +1000 +++ b/app/pitot/pitot.py Wed Feb 28 12:50:06 2018 +1000 @@ -314,7 +314,7 @@ from pitot_output_utils import * from pitot_area_ratio_check import * -VERSION_STRING = "29-Jan-2018" +VERSION_STRING = "28-Feb-2018" DEBUG_PITOT = False
--- a/app/pitot/pitot_input_utils.py Tue Feb 27 09:51:25 2018 +1000 +++ b/app/pitot/pitot_input_utils.py Wed Feb 28 12:50:06 2018 +1000 @@ -906,10 +906,10 @@ print "Facility is {0}. Driver condition is {1}.".format(cfg['facility'], cfg['piston']) print "Driver gas is {0}.".format(cfg['driver_gas']) if cfg['facility'] == 'custom': - if 'driver_composition' in cfg: + if hasattr(states['s4'], 'reactants'): # eq driver print "Facility is {0}. Driver gas is {1}.".format(cfg['facility'], cfg['driver_composition']) - else: - print "Facility is {0}. Driver gas is a perfect gas with gam = {1} and R = {2:.2f}.".format(cfg['facility'], cfg['driver_pg_gam'], cfg['driver_pg_R']) + else: #pg driver + print "Facility is {0}. Driver gas is a perfect gas with gam = {1} and R = {2:.2f}.".format(cfg['facility'], states['s4'].gam, states['s4'].R) print "Driver burst conditions are p4 = {0:.2f} Pa, T4 = {1:.2f} K, M_throat = {2}."\ .format(cfg['p4'], cfg['T4'], cfg['M_throat'])
--- a/app/pitot/pitot_output_utils.py Tue Feb 27 09:51:25 2018 +1000 +++ b/app/pitot/pitot_output_utils.py Wed Feb 28 12:50:06 2018 +1000 @@ -135,21 +135,19 @@ print facility_used txt_output.write(facility_used + '\n') - if cfg['solver'] == 'eq': - if cfg['facility'] != 'custom' and cfg['piston'] in ['Sangdi-1.8MPa', 'sangdi-1.8MPa','Sangdi-2.2MPa', 'sangdi-2.2MPa']: - driver_gas_used = 'Driver gas is {0}.'.format(cfg['driver_gas']) - elif 'driver_pg_gam' not in cfg: # driver will be pg if it is! - driver_gas_used = 'Driver gas is {0} (by {1}).'.format(states['s4'].reactants, states['s4'].outputUnits) + if cfg['solver'] == ['eq','pg-eq']: + if hasattr(states['s4'], 'reactants'): + driver_gas_used = 'Driver gas is {0} (by {1}).'.format(states['s4'].reactants, states['s4'].outputUnits) + elif not hasattr(states['s4'], 'reactants') and cfg['piston'] in ['Sangdi-1.8MPa', 'sangdi-1.8MPa','Sangdi-2.2MPa', 'sangdi-2.2MPa'] and cfg['facility'] != 'custom': + driver_gas_used = 'Driver gas is {0}.'.format(cfg['driver_gas']) else: driver_gas_used = "Driver gas is a perfect gas with gam = {0} and R = {1}."\ - .format(cfg['driver_pg_gam'], cfg['driver_pg_R']) + .format(states['s4'].gam, states['s4'].R) else: if cfg['facility'] != 'custom': driver_gas_used = 'Driver gas is {0}.'.format(cfg['driver_gas']) else: - if 'driver_composition' in cfg and cfg['solver'] in ['eq', 'pg-eq']: - driver_gas_used = 'Driver gas is {0} (by {1}).'.format(cfg['driver_composition'], states['s4'].inputUnits) - elif 'driver_composition' in cfg and cfg['solver'] in ['pg']: + if 'driver_composition' in cfg and cfg['solver'] in ['pg']: driver_gas_used = 'Driver gas is {0} (by {1}).'.format(cfg['driver_composition'], cfg['driver_inputUnits']) else: driver_gas_used = "Driver gas is a perfect gas with gam = {0} and R = {1}."\ @@ -179,7 +177,6 @@ print secondary_driver_pg_line txt_output.write(secondary_driver_pg_line + '\n') - if isinstance(states['s1'], Gas): test_gas_used = 'Test gas (state 1) is {0} (gamma = {1}, R = {2}, {3} by {4}).'.format(cfg['test_gas'],states['s1'].gam,states['s1'].R, states['s1'].reactants, states['s1'].outputUnits) @@ -810,21 +807,20 @@ csv_accelerator_gas_used = 'Custom Accelerator gas (state 5),gamma,{0},R,{1}.'.format(states['s5'].gam,states['s5'].R) else: csv_accelerator_gas_used = "Accelerator gas (state 5),Air." - csv_output.write(csv_accelerator_gas_used + '\n') - - if cfg['solver'] == 'eq': - if cfg['facility'] != 'custom' and cfg['piston'] in ['Sangdi-1.8MPa', 'sangdi-1.8MPa','Sangdi-2.2MPa', 'sangdi-2.2MPa']: - csv_driver_gas_used = 'Driver gas is {0}.'.format(cfg['driver_gas']) + csv_output.write(csv_accelerator_gas_used + '\n') + + if cfg['solver'] in ['eq','pg-eq']: + if hasattr(states['s4'], 'reactants'): + csv_driver_gas_used = 'Driver gas,{0}.'.format(states['s4'].reactants) + elif not hasattr(states['s4'], 'reactants') and cfg['piston'] in ['Sangdi-1.8MPa', 'sangdi-1.8MPa','Sangdi-2.2MPa', 'sangdi-2.2MPa'] and cfg['facility'] != 'custom': + csv_driver_gas_used = 'Driver gas,{0}.'.format(cfg['driver_gas']) else: - csv_driver_gas_used = 'Driver gas,{0}.'.format(states['s4'].reactants) + csv_driver_gas_used = 'Driver gas,pg, gam,{0},R,{1}'.format(states['s4'].gam, states['s4'].R) else: if cfg['facility'] != 'custom': csv_driver_gas_used = 'Driver gas,{0}.'.format(cfg['driver_gas']) else: - if 'driver_composition' in cfg: - csv_driver_gas_used = 'Driver gas,{0}.'.format(cfg['driver_composition']) - else: - csv_driver_gas_used = 'Driver gas,custom pg, gam,{0},R,{1}'.format(cfg['driver_pg_gam'], cfg['driver_pg_R']) + csv_driver_gas_used = 'Driver gas,custom pg, gam,{0},R,{1}'.format(states['s4'].gam, states['s4'].R) csv_output.write(csv_driver_gas_used + '\n') if cfg['secondary']: