r_soviet_overpressure throws error when psi between 1.0-1.5
Opened this issue · 12 comments
e.g., s = r_soviet_overpressure(float(20000), 1.0, float(0), False, "kT", "m", "psi")
Error does not appear to be yield or HOB dependent, purely overpressure below a certain threshold.
File "D:\data\SIOP\ottawa.py", line 19, in
s = r_soviet_overpressure(float(20000), 1.2, float(0), False, "kT", "m", "psi")
File "C:\Users\xxxx\AppData\Local\Programs\Python\Python310\lib\site-packages\glasstone-0.0.1-py3.10.egg\glasstone\overpressure.py", line 869, in r_soviet_overpressure
File "C:\Users\xxxx\AppData\Local\Programs\Python\Python310\lib\site-packages\glasstone-0.0.1-py3.10.egg\glasstone\overpressure.py", line 826, in _rsovietmach
File "C:\Users\xxxx\AppData\Local\Programs\Python\Python310\lib\site-packages\glasstone-0.0.1-py3.10.egg\glasstone\overpressure.py", line 771, in _rsoviet_mach_sh7
glasstone.utilities.ValueOutsideGraphError: -1.0738201869691235
I know it's frustrating, but this is the intended behavior. The r_soviet_overpressure
function is based upon digitized data from a chart in a 1987 Soviet military nuclear weapons effects manual. In order to avoid giving misleading results, I designed all these functions to throw the ValueOutsideGraphError
when they are called with values that aren't included in the original Soviet chart.
One of the deficiencies of the original Soviet charts that overpressure function is based upon is that they do not extend into the very high overpressure range. Since you seem to be interested in very high overpressure (20,000psi) in a case without the thermal layer, I suggest using the Brode overpressure function to plot your case of interest to estimate the ranges at which various overpressures will occur. The Brode equation is supposed to work well into the high overpressure range for cases without the thermal layer.
How are you selecting heights-of-burst? Are you aiming to select an "optimal" HOB for each blast ring, and if so for what burst yields and detonation conditions (thermal precursors etc.)? Depending on quite what you need I may be able to suggest a more elegant solution.
So I've checked and the fixed_point
function in scipy.optimize
should do what you need, e.g.:
optimize.fixed_point(lambda r: brode_overpressure(teters_yield, r, teters_height, opunits='psi'), desired_overpressure)
Can you say more about why optimize.fixed_point
didn't work for you? I checked just now using Python 2 and this worked:
>>> from glasstone.overpressure import brode_overpressure
>>> from scipy import optimize
>>> optimize.fixed_point(lambda r: brode_overpressure(750, r, 2000, opunits='psi'), 5.0)
array(35.0354849668831)
>>> optimize.fixed_point(lambda r: brode_overpressure(750, r, 200, opunits='psi'), 5.0)
array(530.7211266613074)
Wow, now I feel foolish--I had totally misunderstood what optimize.fixed_point
does. But scipy.optimize does contain root finding functions that do what you want:
>>> brode_overpressure(750, 5821, 2000, opunits = 'psi')
4.999922789730555
>>> optimize.bisect(lambda r: brode_overpressure(750, r, 2000, opunits='psi') - 5.0, 1000.0, 10000.0)
5820.946857823928
I believe that you can combine this with the minimization techniques scipy provides to solve your second problem. But these solvers are pretty expensive, so it may be faster in practice (depending on what you're trying to do) to just generate tables and interpolate inside them.
Last year Ivan Stepanov found an old code listing that suggests there's an error in the WSEG-10 model specification I was working from (in the Hanifen AFIT thesis), as well as spotting a couple of other goofs I'd made. He has a version in his fork of the Python library that addresses those issues:
https://github.com/Ivan-Stepanov/glasstone/blob/master/glasstone/fallout.py
And in hindsight the way I implemented WSEG-10 is wildly inefficient. The way I should've done it given that the fallout field has bilateral symmetry would've been to create a spline/interpolation array and then use affine to read from that.
These old "smearing" fallout models and WSEG-10 in particular are of considerable historical interest because they were used in the 1960s and 1970s to evaluate things like McNamara's "assured destruction" criterion, but they aren't the right tool for predicting fallout if you can provide something better. Drawing upon modern transport models like Hysplit or FLEXPART is the right way to go if you have the compute budget. I've looked into it a little bit but I'm not the real expert on it--you should reach out to Stepanov or Sebastien Phillippe, who was doing work on modeling fallout with Hysplit while he was a postdoc at Princeton:
https://sgs.princeton.edu/team/sebastien-philippe
Thanks for acknowledging me in your Python library!