Skip to content

Commit

Permalink
Merge pull request #556 from suavecode/fix-imports
Browse files Browse the repository at this point in the history
Fix imports
  • Loading branch information
planes committed Feb 24, 2022
2 parents 8cd11c1 + cda6106 commit 0aacc7e
Show file tree
Hide file tree
Showing 11 changed files with 168 additions and 100 deletions.
2 changes: 1 addition & 1 deletion regression/scripts/Vehicles/Electric_Multicopter.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ def vehicle_setup():
# Appending rotors with different origins
origins = [[ 0.,2.,1.4],[ 0.0,-2.,1.4],
[2.5,4.,1.4] ,[2.5,-4.,1.4],
[5.0,2.,1.4] ,[5.0,-2.,1.4]]
[5.0,2.,1.4] ,[5.0,-2.,1.4]]

for ii in range(6):
lift_rotor = deepcopy(lift_rotor)
Expand Down
5 changes: 5 additions & 0 deletions trunk/SUAVE/Components/Energy/Converters/Rotor.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ def spin(self,conditions):
Vv = conditions.frames.inertial.velocity_vector
nu = mu/rho
rho_0 = rho
T_0 = T

# Helpful shorthands
pi = np.pi
Expand Down Expand Up @@ -471,6 +472,8 @@ def spin(self,conditions):
Cp = power/(rho_0*(n*n*n)*(D*D*D*D*D))
Crd = rotor_drag/(rho_0*(n*n)*(D*D*D*D))
etap = V*thrust/power
A = np.pi*(R**2 - self.hub_radius**2)
FoM = thrust*np.sqrt(T_0/(2*rho_0*A)) /power

# prevent things from breaking
Cq[Cq<0] = 0.
Expand All @@ -489,6 +492,7 @@ def spin(self,conditions):
Cp[omega==0.0] = 0.0
etap[omega==0.0] = 0.0


# Make the thrust a 3D vector
thrust_prop_frame = np.zeros((ctrl_pts,3))
thrust_prop_frame[:,0] = thrust[:,0]
Expand Down Expand Up @@ -541,6 +545,7 @@ def spin(self,conditions):
blade_H_distribution = rotor_drag_distribution,
rotor_drag = rotor_drag,
rotor_drag_coefficient = Crd,
figure_of_merit = FoM
)
self.outputs = outputs

Expand Down
15 changes: 11 additions & 4 deletions trunk/SUAVE/Core/Container.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
from warnings import warn
import random

import string
chars = string.punctuation + string.whitespace
t_table = str.maketrans( chars + string.ascii_uppercase ,
'_'*len(chars) + string.ascii_lowercase )

# ----------------------------------------------------------------------
# Data Container Base Class
# ----------------------------------------------------------------------
Expand Down Expand Up @@ -97,14 +102,16 @@ def append(self,val):

# See if the item tag exists, if it does modify the name
keys = self.keys()
if str.lower(val.tag) in keys:

tag = str.lower(val.tag.translate(t_table))
if tag in keys:
string_of_keys = "".join(self.keys())
n_comps = string_of_keys.count(val.tag)
val.tag = val.tag + str(n_comps+1)
val.tag = tag + str(n_comps+1)

# Check again, because theres an outside chance that its duplicate again. Then assign a random
if str.lower(val.tag) in keys:
val.tag = val.tag + str(n_comps+random.randint(0,1000))
if val.tag in keys:
val.tag = tag + str(n_comps+random.randint(0,1000))

Data.append(self,val)

Expand Down
15 changes: 10 additions & 5 deletions trunk/SUAVE/Input_Output/OpenVSP/vsp_fuselage.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
# ----------------------------------------------------------------------

## @ingroup Input_Output-OpenVSP
def read_vsp_fuselage(fuselage_id,fux_idx,sym_flag, units_type='SI', fineness=True):
def read_vsp_fuselage(fuselage_id,fux_idx,sym_flag, units_type='SI', fineness=True, use_scaling=True):
"""This reads an OpenVSP fuselage geometry and writes it to a SUAVE fuselage format.
Assumptions:
Expand All @@ -44,8 +44,10 @@ def read_vsp_fuselage(fuselage_id,fux_idx,sym_flag, units_type='SI', fineness=Tr
1. VSP 10-digit geom ID for fuselage.
2. Units_type set to 'SI' (default) or 'Imperial'.
3. Boolean for whether or not to compute fuselage finenesses (default = True).
4. Boolean for whether or not to use the scaling from OpenVSP (default = True).
Outputs:
Writes SUAVE fuselage, with these geometries: (all defaults are SI, but user may specify Imperial)
Fuselages.Fuselage.
Expand Down Expand Up @@ -93,8 +95,11 @@ def read_vsp_fuselage(fuselage_id,fux_idx,sym_flag, units_type='SI', fineness=Tr
fuselage.tag = vsp.GetGeomName(fuselage_id) + '_' + str(fux_idx+1)
else:
fuselage.tag = 'FuselageGeom' + '_' + str(fux_idx+1)

scaling = vsp.GetParmVal(fuselage_id, 'Scale', 'XForm')

if use_scaling:
scaling = vsp.GetParmVal(fuselage_id, 'Scale', 'XForm')
else:
scaling = 1.
units_factor = units_factor*scaling

fuselage.origin[0][0] = vsp.GetParmVal(fuselage_id, 'X_Location', 'XForm') * units_factor
Expand Down Expand Up @@ -342,8 +347,8 @@ def write_vsp_fuselage(fuselage,area_tags, main_wing, fuel_tank_set_ind, OML_set
vals.tail.top.angle = 0.0
vals.tail.top.strength = 0.0

if len(np.unique(x_poses)) != len(x_poses):
raise ValueError('Duplicate fuselage section positions detected.')
#if len(np.unique(x_poses)) != len(x_poses):
#raise ValueError('Duplicate fuselage section positions detected.')
vsp.SetParmVal(fuse_id,"Length","Design",length)
if num_segs != 5: # reduce to only nose and tail
vsp.CutXSec(fuse_id,1) # remove extra default section
Expand Down
6 changes: 3 additions & 3 deletions trunk/SUAVE/Input_Output/OpenVSP/vsp_nacelle.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,9 @@ def read_vsp_nacelle(nacelle_id,vsp_nacelle_type, units_type='SI'):
nacelle.length = abs_x_location_vec[-1]
segs = nacelle.Segments
for seg in range(num_segs):
segs[seg].percent_x_location = np.array(abs_x_location_vec)/abs_x_location_vec[-1]
segs[seg].percent_y_location = np.array(abs_y_location_vec)/abs_x_location_vec[-1]
segs[seg].percent_z_location = np.array(abs_z_location_vec)/abs_x_location_vec[-1]
segs[seg].percent_x_location = np.array(abs_x_location_vec[seg])/abs_x_location_vec[-1]
segs[seg].percent_y_location = np.array(abs_y_location_vec[seg])/abs_x_location_vec[-1]
segs[seg].percent_z_location = np.array(abs_z_location_vec[seg])/abs_x_location_vec[-1]


elif vsp_nacelle_type =='BodyOfRevolution':
Expand Down
Loading

0 comments on commit 0aacc7e

Please sign in to comment.