Mercurial > hg > cfcfd3
changeset 2561:d5a47b74cf1f
app/pitot: added ability to use perfect gas secondary driver and test gases
required changed to a few files, first to set it up, and then change
some of the test section calculations, and then mention that
this had been done in the output
author | Chris James <c.james4@uq.edu.au> |
---|---|
date | Mon, 29 Jan 2018 15:21:41 +1000 |
parents | 2719d01b748e |
children | 0156ca67b9e4 |
files | app/pitot/pitot.py app/pitot/pitot_flow_functions.py app/pitot/pitot_input_utils.py app/pitot/pitot_output_utils.py |
diffstat | 4 files changed, 79 insertions(+), 26 deletions(-) [+] |
line wrap: on
line diff
--- a/app/pitot/pitot.py Fri Jan 19 12:13:53 2018 +1000 +++ b/app/pitot/pitot.py Mon Jan 29 15:21:41 2018 +1000 @@ -314,7 +314,7 @@ from pitot_output_utils import * from pitot_area_ratio_check import * -VERSION_STRING = "17-Jan-2018" +VERSION_STRING = "29-Jan-2018" DEBUG_PITOT = False
--- a/app/pitot/pitot_flow_functions.py Fri Jan 19 12:13:53 2018 +1000 +++ b/app/pitot/pitot_flow_functions.py Mon Jan 29 15:21:41 2018 +1000 @@ -1890,11 +1890,16 @@ states['s10e'] = states[cfg['test_section_state']].clone() states['s10e'].with_ions = True else: - # if it is a pg object (the user did a pg nozzle calculation, probably) + # if it is a pg object (the user did a frozen nozzle calculation or used a perfect gas test gas, probably) # we should make it one... we will copy state1 (test gas fill state) # and then set the temperature and pressure for the test section - states['s10e'] = states['s1'].clone() - states['s10e'].set_pT(states[cfg['test_section_state']].p, states[cfg['test_section_state']].T) + # if they did a frozen nozzle calculation, state 1 will be an eq state, so just copy it + if isinstance(states['s1'], Gas): + states['s10e'] = states['s1'].clone() + states['s10e'].set_pT(states[cfg['test_section_state']].p, states[cfg['test_section_state']].T) + else: # we have a perfect gas test gas state, but a s1-eq state should exist which was used to make state 1 + states['s10e'] = states['s1-eq'].clone() + states['s10e'].set_pT(states[cfg['test_section_state']].p, states[cfg['test_section_state']].T) except Exception as e: print "Error {0}".format(str(e)) if isinstance(states[cfg['test_section_state']], Gas): @@ -2099,13 +2104,21 @@ # if it is an eq gas object, just do what we would normally do... states['s10we'] = states[cfg['test_section_state']].clone() states['s10we'].with_ions = True + states['s10we'].set_pT(states[cfg['test_section_state']].p, states[cfg['test_section_state']].T) else: - # if it is a pg object (the user did a pg nozzle calculation, probably) - # we should make it one... + # if it is a pg object (the user did a frozen nozzle calculation or used a perfect gas test gas, probably) # we should make it one... we will copy state1 (test gas fill state) # and then set the temperature and pressure for the test section - states['s10we'] = states['s1'].clone() - states['s10we'].set_pT(states[cfg['test_section_state']].p, states[cfg['test_section_state']].T) + # if they did a frozen nozzle calculation, state 1 will be an eq state, so just copy it + if isinstance(states['s1'], Gas): + states['s10we'] = states['s1'].clone() + states['s10we'].set_pT(states[cfg['test_section_state']].p, states[cfg['test_section_state']].T) + else: # we have a perfect gas test gas state, but a s1-eq state should exist which was used to make state 1 + states['s10we'] = states['s1-eq'].clone() + states['s10we'].set_pT(states[cfg['test_section_state']].p, states[cfg['test_section_state']].T) + # this is just to help the stuff above, where the test section state may be perfect gas + test_section_state = states['s10we'].clone() + test_section_state.with_ions = True except Exception as e: print "Error {0}".format(str(e)) print "Failed to clone test section gas state." @@ -2131,10 +2144,10 @@ # start by getting the beta angle over the wedge cfg['wedge_angle_radians'] = math.radians(cfg['wedge_angle']) try: - cfg['beta_eq'] = beta_oblique(states[cfg['test_section_state']], V[cfg['test_section_state']], cfg['wedge_angle_radians']) + cfg['beta_eq'] = beta_oblique(test_section_state, V[cfg['test_section_state']], cfg['wedge_angle_radians']) print "Beta = {0} degrees.".format(math.degrees(cfg['beta_eq'])) # now get the wedge surface conditions - cfg['wedge_angle_calculated'], V['s10we'], states['s10we'] = theta_oblique(states[cfg['test_section_state']], V[cfg['test_section_state']], cfg['beta_eq']) + cfg['wedge_angle_calculated'], V['s10we'], states['s10we'] = theta_oblique(test_section_state, V[cfg['test_section_state']], cfg['beta_eq']) wedge_angle_calculated_degrees = math.degrees(cfg['wedge_angle_calculated']) wedge_angle_error = ((cfg['wedge_angle']-wedge_angle_calculated_degrees)/cfg['wedge_angle'])*100.0 # need to check the calculated theta @@ -2235,7 +2248,7 @@ print "state 10cf: p = {0:.2f} Pa, T = {1:.2f} K. V = {2:.2f} m/s.".format(states['s10cf'].p, states['s10cf'].T, V['s10cf']) print 'state 10cf gamma = {0}, state 10cf R = {1}.'.format(states['s10cf'].gam,states['s10cf'].R) - + # ---------------------------------------------------------------------------------------------------- if cfg['solver'] == 'eq' or cfg['solver'] == 'pg-eq': cfg['conehead_completed'] = True #variable we'll set to false if the calculation fails @@ -2245,8 +2258,25 @@ if PRINT_STATUS: print '-'*60 if PRINT_STATUS: print 'Starting equilibrium taylor maccoll conehead calculation on {0} degree conehead.'.format(cfg['conehead_angle']) - - if cfg['conehead_no_ions']: states[cfg['test_section_state']].with_ions = False + + # we need to clone our test section state here, incase it was a perfect gas state + + if isinstance(states[cfg['test_section_state']], Gas): + # if it is an eq gas object, just do what we would normally do and clone a state... + test_section_state = states[cfg['test_section_state']].clone() + else: + # if it is a pg object (the user did a frozen nozzle calculation or used a perfect gas test gas, probably) + # we should make it one... we will copy state1 (test gas fill state) + # and then set the temperature and pressure for the test section + # if they did a frozen nozzle calculation, state 1 will be an eq state, so just copy it + if isinstance(states['s1'], Gas): + test_section_state = states['s1'].clone() + else: # we have a perfect gas test gas state, but a s1-eq state should exist which was used to make state 1 + test_section_state = states['s1-eq'].clone() + + test_section_state.set_pT(states[cfg['test_section_state']].p, states[cfg['test_section_state']].T) + + if cfg['conehead_no_ions']: states[cfg['test_section_state']].with_ions = False try: shock_angle = beta_cone(states[cfg['test_section_state']], V[cfg['test_section_state']], math.radians(cfg['conehead_angle'])) @@ -2258,7 +2288,7 @@ cfg['conehead_no_ions'] = True states[cfg['test_section_state']].with_ions = False try: - shock_angle = beta_cone(states[cfg['test_section_state']], V[cfg['test_section_state']], math.radians(cfg['conehead_angle'])) + shock_angle = beta_cone(test_section_state, V[cfg['test_section_state']], math.radians(cfg['conehead_angle'])) except Exception as e: print "Error {0}".format(str(e)) print "beta_cone function bailed out while trying to find a shock angle." @@ -2270,7 +2300,7 @@ if PRINT_STATUS: print "Shock angle over cone:", math.degrees(shock_angle) # Reverse the process to get the flow state behind the shock and check the surface angle is correct try: - delta_s, V['s10c'], states['s10c'] = theta_cone(states[cfg['test_section_state']], V[cfg['test_section_state']], shock_angle) + delta_s, V['s10c'], states['s10c'] = theta_cone(test_section_state, V[cfg['test_section_state']], shock_angle) except Exception as e: print "Error {0}".format(str(e)) print "theta_cone bailed out while trying to find cone surface conditions."
--- a/app/pitot/pitot_input_utils.py Fri Jan 19 12:13:53 2018 +1000 +++ b/app/pitot/pitot_input_utils.py Mon Jan 29 15:21:41 2018 +1000 @@ -870,8 +870,16 @@ if cfg['facility'] == 'custom' and cfg['effective_gam'] and not isinstance(cfg['effective_gam'], float): print "'effective_gam' must be a float. Current value is not. Bailing out." raise TypeError, "pitot_input_utils.input_checker(): 'effective_gam' input is not a float" - - #------------------ final check stuff....------------------------------- + + # input for the perfect gas secondary driver gas + if 'perfect_gas_secondary_driver' not in cfg: + cfg['perfect_gas_secondary_driver'] = False + + # input for the perfect gas test gas + if 'perfect_gas_test_gas' not in cfg: + cfg['perfect_gas_test_gas'] = False + + #------------------ final check stuff....------------------------------- if cfg['bad_input']: #bail out here if you end up having issues with your input @@ -1300,7 +1308,7 @@ states['sd1'].set_pT(cfg['psd1'],cfg['Tsd1']) - if cfg['solver'] == 'pg': #make perfect gas object if asked to do so, then re-set the gas state + if cfg['solver'] == 'pg' or 'secondary_driver_perfect_gas' in cfg and cfg['secondary_driver_perfect_gas']: #make perfect gas object if asked to do so, then re-set the gas state states['sd1']=pg.Gas(Mmass=states['sd1'].Mmass, gamma=states['sd1'].gam, name='sd1') states['sd1'].set_pT(cfg['psd1'],cfg['Tsd1']) @@ -1346,8 +1354,8 @@ states['s1'].set_pT(float(cfg['p1']),cfg['T1']) #--------------- extra perfect gas or perfect gas eq stuff ------------- - if cfg['solver'] == 'pg' or cfg['solver'] == 'pg-eq': #make perfect gas object if asked to do so, then re-set the gas state - if cfg['solver'] == 'pg-eq': #store the eq gas object as we'll want to come back to it later... + if cfg['solver'] == 'pg' or cfg['solver'] == 'pg-eq' or 'test_gas_perfect_gas' in cfg and cfg['test_gas_perfect_gas']: #make perfect gas object if asked to do so, then re-set the gas state + if cfg['solver'] == 'pg-eq' or 'test_gas_perfect_gas' in cfg and cfg['test_gas_perfect_gas']: #store the eq gas object as we'll want to come back to it later... states['s1-eq'] = states['s1'].clone() if cfg['test_gas'] == 'co2' or cfg['test_gas'] == 'mars' or cfg['test_gas'] == 'venus': #need to force our own gam and Mmass onto the gas object if CO2 is in the gas states['s1'].gam = test_gas_gam; states['s1'].Mmass = test_gas_Mmass
--- a/app/pitot/pitot_output_utils.py Fri Jan 19 12:13:53 2018 +1000 +++ b/app/pitot/pitot_output_utils.py Mon Jan 29 15:21:41 2018 +1000 @@ -172,15 +172,30 @@ secondary_driver_gas_used = 'Secondary driver gas (state sd1) is {0} (gamma = {1}, R = {2}).'.format(cfg['secondary_driver_gas'],states['sd1'].gam,states['sd1'].R) print secondary_driver_gas_used - txt_output.write(secondary_driver_gas_used + '\n') - + txt_output.write(secondary_driver_gas_used + '\n') + + if cfg['solver'] == 'eq' and 'secondary_driver_perfect_gas' in cfg and cfg['secondary_driver_perfect_gas']: + secondary_driver_pg_line = "Secondary driver gas was used as a perfect gas as the user specified this." + 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) elif isinstance(states['s1'], pg.Gas): test_gas_used = 'Test gas (state 1) is {0} (gamma = {1}, R = {2}).'.format(cfg['test_gas'],states['s1'].gam,states['s1'].R) print test_gas_used - txt_output.write(test_gas_used + '\n') + txt_output.write(test_gas_used + '\n') + + if cfg['solver'] == 'eq' and 'test_gas_perfect_gas' in cfg and cfg['test_gas_perfect_gas']: + test_gas_pg_line = "Test gas gas was used as a perfect gas as the user specified this." + print test_gas_pg_line + txt_output.write(test_gas_pg_line + '\n') + + test_gas_pg_test_section_line = "Any eq test section post shock states (s10e, s10c, s10we) were found using an eq test section state also." + print test_gas_pg_test_section_line + txt_output.write(test_gas_pg_test_section_line + '\n') if cfg['custom_accelerator_gas']: if cfg['solver'] == 'eq': @@ -655,9 +670,9 @@ print knudsen_number_state10e_print txt_output.write(knudsen_number_state10e_print + '\n') - - - if cfg['shock_over_model'] and 's10e' in states.keys(): + + # last bit is just to make sure that state 10e is actually an equilibrium state like it always should be! + if cfg['shock_over_model'] and 's10e' in states.keys() and isinstance(states['s10e'], Gas): species1 = 'Species in the shock layer at equilibrium (s10e) (by {0}):'.format(states['s10e'].outputUnits) print species1 txt_output.write(species1 + '\n')