From 0133946b2c04bbde7e6256ba3b29bac458f4b98d Mon Sep 17 00:00:00 2001 From: Tim MacDonald Date: Fri, 28 Jul 2017 11:21:14 -0700 Subject: [PATCH 1/6] added tip creation to openvsp --- trunk/SUAVE/Input_Output/OpenVSP/vsp_write.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/trunk/SUAVE/Input_Output/OpenVSP/vsp_write.py b/trunk/SUAVE/Input_Output/OpenVSP/vsp_write.py index 7c451a5dc5..3dd9a73a90 100644 --- a/trunk/SUAVE/Input_Output/OpenVSP/vsp_write.py +++ b/trunk/SUAVE/Input_Output/OpenVSP/vsp_write.py @@ -176,7 +176,10 @@ def write(vehicle,tag): adjust = 1 # Loop for the number of segments left over - for i_segs in xrange(1,n_segments+1): + for i_segs in xrange(1,n_segments+1): + + if wing.Segments[i_segs-1].percent_span_location == 1.: + break # Unpack dihedral_i = wing.Segments[i_segs-1].dihedral_outboard / Units.deg @@ -210,7 +213,12 @@ def write(vehicle,tag): vsp.Update() - vsp.SetParmVal( wing_id,'Tip_Chord',x_secs[-1-(1-adjust)],tip_chord) + if wing.Segments[-1].percent_span_location == 1.: + tip_chord = root_chord*wing.Segments[-1].root_chord_percent + vsp.SetParmVal( wing_id,'Tip_Chord',x_secs[n_segments-1],tip_chord) + else: + vsp.SetParmVal( wing_id,'Tip_Chord',x_secs[-1-(1-adjust)],tip_chord) + vsp.Update() vsp.SetParmVal(wing_id,'CapUMaxOption','EndCap',2.) vsp.SetParmVal(wing_id,'CapUMaxStrength','EndCap',1.) From e76cfcf0a939cd4a949cc6735575b7cd1817429b Mon Sep 17 00:00:00 2001 From: Tim MacDonald Date: Fri, 28 Jul 2017 17:15:28 -0700 Subject: [PATCH 2/6] geometries match --- .../AVL/create_avl_datastructure.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/trunk/SUAVE/Methods/Aerodynamics/AVL/create_avl_datastructure.py b/trunk/SUAVE/Methods/Aerodynamics/AVL/create_avl_datastructure.py index 64c140bc86..21b8adc4f8 100644 --- a/trunk/SUAVE/Methods/Aerodynamics/AVL/create_avl_datastructure.py +++ b/trunk/SUAVE/Methods/Aerodynamics/AVL/create_avl_datastructure.py @@ -92,19 +92,27 @@ def populate_wing_sections(avl_wing,suave_wing): # obtain the geometry for each segment in a loop for i_segs in xrange(n_segments): # convert quarter chord sweeps to leading edge sweeps + dihedral = suave_wing.Segments[i_segs].dihedral_outboard if (i_segs == n_segments-1): sweep = 0 else: if suave_wing.Segments[i_segs].sweeps.leading_edge > 0: sweep = suave_wing.Segments[i_segs].sweeps.leading_edge + segment_span = semispan*(suave_wing.Segments[i_segs+1].percent_span_location - suave_wing.Segments[i_segs].percent_span_location ) + span_no_dihedral = segment_span/np.cos(dihedral) else: sweep_quarter_chord = suave_wing.Segments[i_segs].sweeps.quarter_chord chord_fraction = 0.25 # quarter chord segment_root_chord = root_chord*suave_wing.Segments[i_segs].root_chord_percent segment_tip_chord = root_chord*suave_wing.Segments[i_segs+1].root_chord_percent segment_span = semispan*(suave_wing.Segments[i_segs+1].percent_span_location - suave_wing.Segments[i_segs].percent_span_location ) - sweep = np.arctan(((segment_root_chord*chord_fraction) + (np.tan(sweep_quarter_chord )*segment_span - chord_fraction*segment_tip_chord)) /segment_span) - dihedral = suave_wing.Segments[i_segs].dihedral_outboard + + span_no_dihedral = segment_span/np.cos(dihedral) + dx_quarter = span_no_dihedral*np.tan(sweep_quarter_chord) + segment_root_chord/4. + dx_leading_edge = dx_quarter - segment_tip_chord/4. + + sweep = np.arctan(dx_leading_edge/span_no_dihedral) + section = Section() section.tag = suave_wing.Segments[i_segs].tag section.chord = root_chord*suave_wing.Segments[i_segs].root_chord_percent @@ -125,15 +133,13 @@ def populate_wing_sections(avl_wing,suave_wing): dz = semispan*segment_percent_span dy = dz*np.tan(dihedral) - l = dz/np.cos(dihedral) - dx = l*np.tan(sweep) + dx = span_no_dihedral*np.tan(sweep) origin.append( [origin[i_segs][0] + dx , origin[i_segs][1] + dy, origin[i_segs][2] + dz]) else: dy = semispan*segment_percent_span dz = dy*np.tan(dihedral) - l = dy/np.cos(dihedral) - dx = l*np.tan(sweep) + dx = span_no_dihedral*np.tan(sweep) origin.append( [origin[i_segs][0] + dx , origin[i_segs][1] + dy, origin[i_segs][2] + dz]) else: symm = avl_wing.symmetric From c8a4852d1c986926572c5d54d826804bf8ca205d Mon Sep 17 00:00:00 2001 From: Tim MacDonald Date: Fri, 28 Jul 2017 18:02:11 -0700 Subject: [PATCH 3/6] fixed avl trap wing --- trunk/SUAVE/Input_Output/OpenVSP/vsp_write.py | 9 +++++-- .../AVL/create_avl_datastructure.py | 24 ++++++++++++------- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/trunk/SUAVE/Input_Output/OpenVSP/vsp_write.py b/trunk/SUAVE/Input_Output/OpenVSP/vsp_write.py index 3dd9a73a90..9e2cfa390f 100644 --- a/trunk/SUAVE/Input_Output/OpenVSP/vsp_write.py +++ b/trunk/SUAVE/Input_Output/OpenVSP/vsp_write.py @@ -186,6 +186,7 @@ def write(vehicle,tag): chord_i = root_chord*wing.Segments[i_segs-1].root_chord_percent twist_i = wing.Segments[i_segs-1].twist / Units.deg sweep_i = wing.Segments[i_segs-1].sweeps.quarter_chord / Units.deg + tc_i = wing.Segments[i_segs-1].thickness_to_chord # Calculate the local span if i_segs == n_segments: @@ -209,15 +210,19 @@ def write(vehicle,tag): vsp.SetParmVal( wing_id,'Sweep_Location',x_secs[i_segs+adjust],sweep_loc) vsp.SetParmVal( wing_id,'Root_Chord',x_secs[i_segs+adjust],chord_i) vsp.SetParmVal( wing_id,'Twist',x_secs[i_segs+adjust],twist_i) - vsp.SetParmVal( wing_id,'ThickChord',x_sec_curves[i_segs+adjust],tip_tc) + vsp.SetParmVal( wing_id,'ThickChord',x_sec_curves[i_segs+adjust],tc_i) vsp.Update() - if wing.Segments[-1].percent_span_location == 1.: + if (n_segments != 0) and (wing.Segments[-1].percent_span_location == 1.): tip_chord = root_chord*wing.Segments[-1].root_chord_percent vsp.SetParmVal( wing_id,'Tip_Chord',x_secs[n_segments-1],tip_chord) + vsp.SetParmVal( wing_id,'Twist',x_secs[n_segments-1],wing.Segments[-1].twist / Units.deg) + vsp.SetParmVal( wing_id,'ThickChord',x_secs[n_segments-1],wing.Segments[-1].thickness_to_chord) else: vsp.SetParmVal( wing_id,'Tip_Chord',x_secs[-1-(1-adjust)],tip_chord) + vsp.SetParmVal( wing_id,'Twist',x_secs[-1-(1-adjust)],tip_twist) + # a single trapezoidal wing is assumed to have constant thickness to chord vsp.Update() vsp.SetParmVal(wing_id,'CapUMaxOption','EndCap',2.) vsp.SetParmVal(wing_id,'CapUMaxStrength','EndCap',1.) diff --git a/trunk/SUAVE/Methods/Aerodynamics/AVL/create_avl_datastructure.py b/trunk/SUAVE/Methods/Aerodynamics/AVL/create_avl_datastructure.py index 21b8adc4f8..6cdfb5f363 100644 --- a/trunk/SUAVE/Methods/Aerodynamics/AVL/create_avl_datastructure.py +++ b/trunk/SUAVE/Methods/Aerodynamics/AVL/create_avl_datastructure.py @@ -3,6 +3,7 @@ # Created: Oct 2014, T. Momose # Modified: Jan 2016, E. Botero # Apr 2017, M. Clarke +# Jul 2017, T. MacDonald # ---------------------------------------------------------------------- # Imports @@ -106,11 +107,9 @@ def populate_wing_sections(avl_wing,suave_wing): segment_root_chord = root_chord*suave_wing.Segments[i_segs].root_chord_percent segment_tip_chord = root_chord*suave_wing.Segments[i_segs+1].root_chord_percent segment_span = semispan*(suave_wing.Segments[i_segs+1].percent_span_location - suave_wing.Segments[i_segs].percent_span_location ) - span_no_dihedral = segment_span/np.cos(dihedral) dx_quarter = span_no_dihedral*np.tan(sweep_quarter_chord) + segment_root_chord/4. dx_leading_edge = dx_quarter - segment_tip_chord/4. - sweep = np.arctan(dx_leading_edge/span_no_dihedral) section = Section() @@ -142,12 +141,12 @@ def populate_wing_sections(avl_wing,suave_wing): dx = span_no_dihedral*np.tan(sweep) origin.append( [origin[i_segs][0] + dx , origin[i_segs][1] + dy, origin[i_segs][2] + dz]) else: - symm = avl_wing.symmetric - sweep = suave_wing.sweeps.quarter_chord - dihedral = suave_wing.dihedral - span = suave_wing.spans.projected - semispan = suave_wing.spans.projected * 0.5 * (2 - symm) - origin = suave_wing.origin + symm = avl_wing.symmetric + sweep_quarter_chord = suave_wing.sweeps.quarter_chord + dihedral = suave_wing.dihedral + span = suave_wing.spans.projected + semispan = suave_wing.spans.projected * 0.5 * (2 - symm) + origin = suave_wing.origin root_section = Section() root_section.tag = 'root_section' @@ -159,7 +158,14 @@ def populate_wing_sections(avl_wing,suave_wing): tip_section.tag = 'tip_section' tip_section.chord = suave_wing.chords.tip tip_section.twist = suave_wing.twists.tip - tip_section.origin = [origin[0]+semispan*np.tan(sweep),origin[1]+semispan,origin[2]+semispan*np.tan(dihedral)] + + semispan_no_dihedral = semispan/np.cos(dihedral) + dx_quarter = semispan_no_dihedral*np.tan(sweep_quarter_chord) + root_section.chord/4. + dx_leading_edge = dx_quarter - tip_section.chord/4. + sweep = np.arctan(dx_leading_edge/semispan_no_dihedral) + dx = semispan_no_dihedral*np.tan(sweep) + + tip_section.origin = [origin[0]+dx, origin[1]+semispan, origin[2]+semispan*np.tan(dihedral)] if avl_wing.vertical: temp = tip_section.origin[2] From 9ab7d4409e83fe2be76a7f765852f34c48d974f0 Mon Sep 17 00:00:00 2001 From: Tim MacDonald Date: Fri, 28 Jul 2017 18:04:53 -0700 Subject: [PATCH 4/6] header update --- trunk/SUAVE/Input_Output/OpenVSP/vsp_write.py | 1 + 1 file changed, 1 insertion(+) diff --git a/trunk/SUAVE/Input_Output/OpenVSP/vsp_write.py b/trunk/SUAVE/Input_Output/OpenVSP/vsp_write.py index 9e2cfa390f..7a4ce11d5d 100644 --- a/trunk/SUAVE/Input_Output/OpenVSP/vsp_write.py +++ b/trunk/SUAVE/Input_Output/OpenVSP/vsp_write.py @@ -2,6 +2,7 @@ # # Created: Jul 2016, T. MacDonald # Modified: Jun 2017, T. MacDonald +# Jul 2017, T. MacDonald # ---------------------------------------------------------------------- # Imports From 3160ccc68e9fc6ba6f6ccdab3d588d2eef5492a4 Mon Sep 17 00:00:00 2001 From: Tim MacDonald Date: Mon, 31 Jul 2017 14:41:20 -0700 Subject: [PATCH 5/6] twist updates --- trunk/SUAVE/Input_Output/OpenVSP/vsp_write.py | 37 ++++++++++++++----- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/trunk/SUAVE/Input_Output/OpenVSP/vsp_write.py b/trunk/SUAVE/Input_Output/OpenVSP/vsp_write.py index 7a4ce11d5d..182e9df0c1 100644 --- a/trunk/SUAVE/Input_Output/OpenVSP/vsp_write.py +++ b/trunk/SUAVE/Input_Output/OpenVSP/vsp_write.py @@ -94,9 +94,18 @@ def write(vehicle,tag): vsp.SetParmVal( wing_id,'Sweep_Location',x_secs[1],sweep_loc) # Twists - vsp.SetParmVal( wing_id,'Twist',x_secs[0],tip_twist) # tip - vsp.SetParmVal( wing_id,'Twist',x_secs[0],root_twist) # root - + if n_segments != 0: + if wing.Segments[0].percent_span_location == 0.: + vsp.SetParmVal( wing_id,'Twist',x_secs[0],wing.Segments[0].twist / Units.deg) # root + else: + vsp.SetParmVal( wing_id,'Twist',x_secs[0],root_twist) # root + if wing.Segments[-1].percent_span_location == 1.: + vsp.SetParmVal( wing_id,'Twist',x_secs[-2],wing.Segments[0].twist / Units.deg) # root + else: + vsp.SetParmVal( wing_id,'Twist',x_secs[-2],tip_twist) # root + else: + vsp.SetParmVal( wing_id,'Twist',x_secs[0],root_twist) # root + vsp.SetParmVal( wing_id,'Twist',x_secs[0],tip_twist) # tip # Figure out if there is an airfoil provided # Airfoils should be in Lednicer format @@ -175,17 +184,22 @@ def write(vehicle,tag): adjust = 1 else: adjust = 1 + # Loop for the number of segments left over for i_segs in xrange(1,n_segments+1): - if wing.Segments[i_segs-1].percent_span_location == 1.: + if (wing.Segments[i_segs-1] == wing.Segments[-1]) and (wing.Segments[-1].percent_span_location == 1.): break # Unpack dihedral_i = wing.Segments[i_segs-1].dihedral_outboard / Units.deg chord_i = root_chord*wing.Segments[i_segs-1].root_chord_percent - twist_i = wing.Segments[i_segs-1].twist / Units.deg + try: + twist_i = wing.Segments[i_segs].twist / Units.deg + no_twist_flag = False + except: + no_twist_flag = True sweep_i = wing.Segments[i_segs-1].sweeps.quarter_chord / Units.deg tc_i = wing.Segments[i_segs-1].thickness_to_chord @@ -210,16 +224,21 @@ def write(vehicle,tag): vsp.SetParmVal( wing_id,'Sweep',x_secs[i_segs+adjust],sweep_i) vsp.SetParmVal( wing_id,'Sweep_Location',x_secs[i_segs+adjust],sweep_loc) vsp.SetParmVal( wing_id,'Root_Chord',x_secs[i_segs+adjust],chord_i) - vsp.SetParmVal( wing_id,'Twist',x_secs[i_segs+adjust],twist_i) + if not no_twist_flag: + vsp.SetParmVal( wing_id,'Twist',x_secs[i_segs+adjust],twist_i) vsp.SetParmVal( wing_id,'ThickChord',x_sec_curves[i_segs+adjust],tc_i) + if adjust and (i_segs == 1): + vsp.Update() + vsp.SetParmVal( wing_id,'Twist',x_secs[1],wing.Segments[i_segs-1].twist / Units.deg) + vsp.Update() if (n_segments != 0) and (wing.Segments[-1].percent_span_location == 1.): tip_chord = root_chord*wing.Segments[-1].root_chord_percent - vsp.SetParmVal( wing_id,'Tip_Chord',x_secs[n_segments-1],tip_chord) - vsp.SetParmVal( wing_id,'Twist',x_secs[n_segments-1],wing.Segments[-1].twist / Units.deg) - vsp.SetParmVal( wing_id,'ThickChord',x_secs[n_segments-1],wing.Segments[-1].thickness_to_chord) + vsp.SetParmVal( wing_id,'Tip_Chord',x_secs[n_segments-1+adjust],tip_chord) + #vsp.SetParmVal( wing_id,'Twist',x_secs[n_segments-1],wing.Segments[-1].twist / Units.deg) + vsp.SetParmVal( wing_id,'ThickChord',x_secs[n_segments-1+adjust],wing.Segments[-1].thickness_to_chord) else: vsp.SetParmVal( wing_id,'Tip_Chord',x_secs[-1-(1-adjust)],tip_chord) vsp.SetParmVal( wing_id,'Twist',x_secs[-1-(1-adjust)],tip_twist) From 84c097b7f5af46d64214aa31d7e08fabb310b939 Mon Sep 17 00:00:00 2001 From: Tim MacDonald Date: Mon, 31 Jul 2017 14:51:01 -0700 Subject: [PATCH 6/6] comment update --- trunk/SUAVE/Input_Output/OpenVSP/vsp_write.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trunk/SUAVE/Input_Output/OpenVSP/vsp_write.py b/trunk/SUAVE/Input_Output/OpenVSP/vsp_write.py index 182e9df0c1..addabc8d77 100644 --- a/trunk/SUAVE/Input_Output/OpenVSP/vsp_write.py +++ b/trunk/SUAVE/Input_Output/OpenVSP/vsp_write.py @@ -237,8 +237,8 @@ def write(vehicle,tag): if (n_segments != 0) and (wing.Segments[-1].percent_span_location == 1.): tip_chord = root_chord*wing.Segments[-1].root_chord_percent vsp.SetParmVal( wing_id,'Tip_Chord',x_secs[n_segments-1+adjust],tip_chord) - #vsp.SetParmVal( wing_id,'Twist',x_secs[n_segments-1],wing.Segments[-1].twist / Units.deg) vsp.SetParmVal( wing_id,'ThickChord',x_secs[n_segments-1+adjust],wing.Segments[-1].thickness_to_chord) + # twist is set in the normal loop else: vsp.SetParmVal( wing_id,'Tip_Chord',x_secs[-1-(1-adjust)],tip_chord) vsp.SetParmVal( wing_id,'Twist',x_secs[-1-(1-adjust)],tip_twist)