Skip to content

Commit c521c0a

Browse files
committed
turning off altitude
1 parent 177aaf1 commit c521c0a

File tree

3 files changed

+41
-16
lines changed

3 files changed

+41
-16
lines changed

pyNastran/f06/dev/flutter/utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
def load_f06_op2(f06_filename: str, log: SimpleLogger,
1616
in_units: str,
1717
out_units: str,
18-
use_rhoref: bool) -> tuple[OP2, dict[int, FlutterResponse]]:
18+
use_rhoref: bool,
19+
make_alt: bool=False) -> tuple[OP2, dict[int, FlutterResponse]]:
1920
"""
2021
load a Vg-Vf plot from:
2122
- OP2 / F06
@@ -43,6 +44,7 @@ def load_f06_op2(f06_filename: str, log: SimpleLogger,
4344
f06_units=in_units_dict,
4445
out_units=out_units_dict,
4546
use_rhoref=use_rhoref,
47+
make_alt=make_alt,
4648
log=log)
4749
except Exception as e:
4850
log.error(str(e))

pyNastran/f06/flutter_response.py

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -575,10 +575,6 @@ def _set_pknl_results(self,
575575

576576
vel_units_in = in_units['velocity']
577577
q_units_in = in_units['dynamic_pressure']
578-
if _is_q_units_consistent(density_units_in, vel_units_in, q_units_in):
579-
q = 0.5 * rho * vel**2
580-
else: # pragma: no cover
581-
raise NotImplementedError((density_units_in, vel_units_in, q_units_in))
582578

583579
# eas = (2 * q / rho_ref)**0.5
584580
# eas = V * sqrt(rho / rhoSL)
@@ -590,27 +586,35 @@ def _set_pknl_results(self,
590586
altitude_units = in_units['altitude']
591587

592588
# print('density_units_in=%r density_units2=%r' % (density_units_in, density_units2))
593-
kdensityi = convert_density(1., density_units_in, 'slug/ft^3')
594-
595589
resultsi = results[:, :, :9]
596590
assert resultsi.shape[2] == 9, resultsi.shape
597591

598-
rho_in_slug_ft3 = rho * kdensityi
592+
rho_in_slug_ft3 = rho_ref * rho
599593
ft_to_alt_unit = convert_altitude(1., 'ft', altitude_units)
600594
if self.make_alt:
595+
nrho = len(rho)
601596
alt_ft = []
602597
for idensity, densityi in enumerate(rho_in_slug_ft3.ravel()):
603598
try:
604599
alt_fti = get_alt_for_density(densityi, density_units='slug/ft^3',
605-
alt_units='ft', nmax=20)
600+
alt_units='ft', nmax=50)
606601
except Exception:
607-
raise RuntimeError(f'failed to find altitude for density[{idensity}]='
608-
f'{rho.ravel()[idensity]:g}; density_units_in={density_units_in!r}')
602+
raise RuntimeError(f'Case {idensity+1}/{nrho}: failed to find altitude for density='
603+
f'{rho.ravel()[idensity]:g}; density_units_in={density_units_in!r} ({densityi:g} slug/ft^3)\n'
604+
' output_rho_range = rho_ref * input_rho_range\n'
605+
f' rho_ref: {rho_ref:g} {density_units_in}\n'
606+
f' input_rho_range: [{rho.min():g}, {rho.max()}]\n'
607+
f' => output_rho_range: [{rho_in_slug_ft3.min():g}, {rho_in_slug_ft3.max()}] slug/ft^3')
609608
alt_ft.append(alt_fti)
610609
alt = np.array(alt_ft, dtype=rho.dtype).reshape(vel.shape) * ft_to_alt_unit
611610
else:
612611
alt = np.full(vel.shape, np.nan, dtype=vel.dtype)
613612

613+
# get dynamic pressure
614+
if _is_q_units_consistent(density_units_in, vel_units_in, q_units_in):
615+
q = 0.5 * rho * vel**2
616+
else: # pragma: no cover
617+
raise NotImplementedError((density_units_in, vel_units_in, q_units_in))
614618
results2 = np.dstack([resultsi, eas, q, alt])
615619
# results2[:, :, self.idensity] = rho
616620
return results2
@@ -809,6 +813,9 @@ def get_flutter_crossings(self,
809813
easi, dampi, freqi = remove_eas_range(
810814
easi, dampi, freqi, eas_range)
811815

816+
if len(freqi) == 0:
817+
continue
818+
812819
for damping_targeti, damping_requiredi in damping_crossings_dict.items():
813820
if dampi.max() < damping_requiredi:
814821
continue
@@ -1796,6 +1803,8 @@ def plot_vg_vf(self, fig=None, damp_axes=None, freq_axes=None,
17961803
vel_calc, damping_calc, freq_calc = remove_eas_range(
17971804
vel, damping, freq, eas_range)
17981805

1806+
if len(freq) == 0:
1807+
continue
17991808
jcolor, color, linestyle2, symbol2, texti, is_removedi = _increment_jcolor(
18001809
mode, jcolor, color, linestyle, symbol,
18011810
freq, damping, freq_tol=freq_tol, freq_tol_remove=freq_tol_remove,
@@ -3653,14 +3662,22 @@ def _get_divergence(self,
36533662
dampi = self.results[imode, :, self.idamping].flatten()
36543663
easi = self.results[imode, :, self.ieas].flatten()
36553664
freqi = self.results[imode, :, self.ifreq].flatten()
3656-
36573665
easi, dampi, freqi = remove_excluded_points(
36583666
easi, dampi, freqi, point_removal)
36593667
easi, dampi, freqi = remove_eas_range(
36603668
easi, dampi, freqi, eas_range)
36613669

3670+
if len(freqi) == 0:
3671+
continue
3672+
36623673
for freq_targeti, freq_requiredi in freq_crossings_dict.items():
3663-
if freqi.min() > freq_requiredi:
3674+
try:
3675+
freqi_min = freqi.min()
3676+
except:
3677+
warnings.warn(f'mode={mode}; freqi={freqi}')
3678+
raise
3679+
3680+
if freqi_min > freq_requiredi:
36643681
continue
36653682

36663683
# dfreq sign is flipped because get_zero_crossings

pyNastran/f06/parse_flutter.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ def make_flutter_response(f06_filename: PathLike,
3939
f06_units=None, out_units=None,
4040
use_rhoref: bool=False,
4141
read_flutter: bool=True,
42+
make_alt: bool=True,
4243
log: Optional[SimpleLogger]=None) -> tuple[dict[int, FlutterResponse],
4344
dict[str, Any]]:
4445
"""
@@ -57,7 +58,10 @@ def make_flutter_response(f06_filename: PathLike,
5758
False: assume the density in the table is absolute density
5859
True: assume the density should be defined by sea level density,
5960
so density is a density ratio
60-
61+
read_flutter : bool; default=True
62+
don't parse the flutter to extract eigenvalues/mass
63+
make_alt : bool; default=True
64+
make altitude an output variable
6165
6266
Returns
6367
-------
@@ -225,7 +229,8 @@ def make_flutter_response(f06_filename: PathLike,
225229
in_units=f06_units,
226230
use_rhoref=use_rhoref,
227231
eigenvector=eigenvectors_array,
228-
eigr_eigi_velocity=eigr_eigi_velocity)
232+
eigr_eigi_velocity=eigr_eigi_velocity,
233+
make_alt=make_alt)
229234
response.set_out_units(out_units)
230235
#_remove_neutrinos(response, log)
231236
flutters[subcase] = response
@@ -426,7 +431,8 @@ def make_flutter_response(f06_filename: PathLike,
426431
in_units=f06_units,
427432
use_rhoref=use_rhoref,
428433
eigenvector=eigenvectors_array,
429-
eigr_eigi_velocity=eigr_eigi_velocity)
434+
eigr_eigi_velocity=eigr_eigi_velocity,
435+
make_alt=make_alt)
430436
response.set_out_units(out_units)
431437
flutters[subcase] = response
432438

0 commit comments

Comments
 (0)