-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathdecode2.py
More file actions
1704 lines (1468 loc) · 78.5 KB
/
decode2.py
File metadata and controls
1704 lines (1468 loc) · 78.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Example script for building a twin boom UAV geometry.
# ==============================================================================
# AirCONICS
# Aircraft CONfiguration through Integrated Cross-disciplinary Scripting
# version 0.1.1
# Andras Sobester, 2014.
# Bug reports to a.sobester@soton.ac.uk or @ASobester please.
# ==============================================================================
from __future__ import division
import math, rhinoscriptsyntax as rs
import primitives
import airconics_setup
import liftingsurface
#import liftingsurface_old as liftingsurface
import AirCONICStools as act
import HighLiftDevices as HLD
from harpoon_cfg import harpoonData
from harpoon_cfg import harpoonRefZone
from harpoon_cfg import harpoonClose
from XFLR5XML import XFLR5Data
from XFLR5XML import XFLR5MainWing
from XFLR5XML import XFLR5Elevator
from XFLR5XML import XFLR5Fin
from XFLR5XML import XFLR5Close
from fluent_jou import fluentData
from fluent_jou import fluentBCs
from fluent_jou import fluentModel
from fluent_jou import fluentMethod
from fluent_jou import fluentInitc
from fluent_jou import fluentCalc
from fluent_jou import fluentAdapt
from fluent_jou import fluentRunOn
from fluent_jou import fluentReport
from datfilegen import curve2dat
global BoomInner, BoomOuter
global SettingAngle, TaperRatio
global fo
rs.UnitAbsoluteTolerance( 0.0001 )
rs.UnitAngleTolerance(0.1)
rs.UnitRelativeTolerance(0.1)
#===============================================================================
# EXAMPLE - Decode2 pusher UAV
#===============================================================================
# Name = Value # Long Name / Definition
Awing = 1554100.3 # total wing area
AR = 10.0 # aspect ratio (span^2 / area)
Span = 3942.2 # total wing span (rect wing)
Chord = 394.2 # aerodynamic mean chord
Dprop = 550.4 # propellor diameter
Span_tail = 784.7 # tailplane span
Chord_tail = 196.2 # tailplane mean chord
Atail = 153943.6 # tailplane area
ARtail = 4.0 # tailplane aspect ratio (span^2 / area)
Height_fin = 303.9 # fin height (or semi-span) for two fins
Chord_fin = 202.6 # fin mean chord
Depth_Fuse = 225.0 # fuselage depth
Width_Fuse = 250.0 # fuselage width
Len_Nose = 200.0 # nose length (forward of front bulkhead)
Dia_Wheels = 125.0 # diam of main undercariage wheels
Len_Engine = 150.0 # length of engine
x_fnt_bkhd = 644.2 # long position of front bulkhead
x_tail_spar = -1407.0 # long position of tailplane spar
x_rear_bkhd = -250.0 # long position of rear bulkhead
x_mid_bkhd = 197.1 # long position of middle bulkhead
z_fuse_base = -110.0 # vert position of base of fuselage
z_tail_boom = 0.0 # vert position of tailboom
z_engine = 60.0 # vert position of engine
z_uncarriage = -325.0 # vert position of centre of main undercarriage wheels
y_tail_boom = 302.7 # horizontal position of tail booms
x_main_spar = 0.0 # long position of main spar
Vmax_C = 30.00 # maximum cruise speed
V_L = 12.50 # landing speed
V_T = 16.00 # take-off speed
Pr_C = 998.68 # Pressure at cruise height
rho_C = 1.2107 # Density at cruise height
Vsound_C = 339.71 # Speed of Sound at crusie height
Re_C = 802099.8 # Reynolds No at crusie height and speed
Visc_C = 1.785E-05 # Visc. at cruise height
FinAngle = 90
TaperRatio = 0.667
VTail = True
SWEEP_QTR_deg = 0
Pod = True
NoseGear = True
Ailerons = False
ASpanStart = 0.6
ASpanEnd = 0.98
AChord = 0.3
ATaper = 1.0
ADeflectionAngle = 0.0
Elevators = False
ESpanStart = 0.01
ESpanEnd = 0.98
EChord = 0.3
ETaper = 1.0
EDeflectionAngle = 0.0
Rudder = False
RSpanStart = 0.0555
RSpanEnd = 0.98
RChord = 0.3
RTaper = 1.0
RDeflectionAngle = 0.0
# turn on the control surfaces
Ailerons = True
Elevators = True
Rudder = True
# cut up the structure if needed
CutStructure = True
RibThick = 0.005
CutterSize = 5
MainSparODia = 0.02
MainSparIDia = 0.016
BoomODia = 0.02
BoomIDia = 0.016
TailSparODia = 0.016
TailSparIDia = 0.013
FinSparODia = 0.01
FinSparIDia = 0.008
HingeSparODia = 0.005
HingeSparIDia = 0.003
SparClearance = 0.0
# meshing details for Harpoon
DesiredyPlus = 75.0 # use 75 for coarse mesh and 1 for fine one
RefLev = 4 # use 4 for coarse mesh and 5 for fine one
# (nb tailplane outer zones are one level coarser)
FirstCellHtMult = 60 # multiply by 60 for coarse mesh and 2500 for fine one
# meshing details for Harpoon (if using symmetry edit farfield ymin to be -0.5
# in body units) note that Fluent scripts should include y+ adaptation as well
# also turn of BL mesh for coarse model as Fluent will adapt back what is reqd
DesiredyPlus = 0.8 # use 30 for coarse mesh and 1.7 for fine one
RefLev = 3 # use 2 for coarse mesh and 3 for fine one
# (nb tailplane outer zones are one level coarser)
FirstCellHtMult = 2500 # multiply by 250 for coarse mesh and 5000 for fine one
def domain_gen(surface_id):
if surface_id:
domainU = rs.SurfaceDomain( surface_id, 0)
print domainU
u0 = domainU[0]
u1 = domainU[1]
domainV = rs.SurfaceDomain( surface_id, 1)
print domainV
v0 = domainV[0]
v1 = domainV[1]
return u0, u1, v0, v1
else:
print ("domain generation error")
def ExtractTrailingEdge(surface_id):
u0, u1, v0, v1 = domain_gen(surface_id)
TE_Curve = rs.AddInterpCrvOnSrfUV(surface_id, [[u0,v0],[u1,v0]])
return TE_Curve
def myDihedralFunctionTractor(Epsilon):
# User-defined function describing the variation of dihedral as a function
# of the leading edge coordinate
return 0
def myTwistFunctionTractor(Epsilon):
# User-defined function describing the variation of twist as a function
# of the leading edge coordinate
RootTwist = 0
TipTwist = 2 # typical reduction in twist to give washout
TipTwist = 0
return RootTwist + Epsilon*(TipTwist-RootTwist)
def myChordFunctionTractor(Epsilon):
# User-defined function describing the variation of chord as a function of
# the leading edge coordinate
if Epsilon < 0.2:
return 1
else:
ChordLengths = [1, TaperRatio]
EpsArray = [0.2, 1]
f = act.linear_interpolation(EpsArray, ChordLengths)
return f(Epsilon)
def myAirfoilFunctionTractor(Epsilon, LEPoint, ChordFunct, ChordFactor, \
DihedralFunct, TwistFunct):
# Defines the variation of cross section as a function of Epsilon
AirfoilChordLength = (ChordFactor*ChordFunct(Epsilon))/math.cos \
(math.radians(TwistFunct(Epsilon)))
# Instantiate class to set up a generic airfoil with these basic parameters
Af = primitives.Airfoil(LEPoint, AirfoilChordLength, DihedralFunct(Epsilon)\
, TwistFunct(Epsilon),
EnforceSharpTE = True)
SmoothingPasses = 1
# Add NACA2212 airfoil curve to document and retrieve handles to it and
# its chord
# MaxCamberPercChord = 2, MaxCamberLocTenthChord = 2,
# MaxThicknessPercChord = 12
# Airf,Chrd = primitives.Airfoil.AddNACA4(Af, 0, 0, 12, SmoothingPasses)
# Add airfoil curve to document and retrieve handles to it and its chord
# - in this case NACA23012, with DesignLiftCoefficient = 0.3,
# MaxCamberLocFracChord = 0.15 and MaxThicknessPercChord = 15
Airf,Chrd = primitives.Airfoil.AddNACA5(Af, 0.3, 0.15, 15, SmoothingPasses)
return Airf, Chrd
def mySweepAngleFunctionTractor(Epsilon):
# User-defined function describing the variation of sweep angle as a
# function of the leading edge coordinate
return 0
#======== TAILPLANE ============================================================
def myTwistFunctionTailplane(Epsilon):
# User-defined function describing the variation of twist as a function
# of the leading edge coordinate
# 2.85 gives the correct trim at 30 m/s with zero main wing setting angle
# according to XFLR5
#RootTwist = 2.85
#TipTwist = 2.85
# 0.34 gives the correct trim at 30 m/s with 2.53 main wing setting angle
# according to XFLR5
RootTwist = 0.34
TipTwist = 0.34
# RootTwist = 8.0
# TipTwist = 8.0
#RootTwist = 0.0
#TipTwist = 0.0
return RootTwist + Epsilon*(TipTwist-RootTwist)
def myChordFunctionTailplane(Epsilon):
# User-defined function describing the variation of chord as a function of
# the leading edge coordinate
return 1
def myAirfoilFunctionTailplane(Epsilon, LEPoint, ChordFunct, ChordFactor,\
DihedralFunct, TwistFunct):
# Defines the variation of cross section as a function of Epsilon
AirfoilChordLength = (ChordFactor*ChordFunct(Epsilon))/math.cos\
(math.radians(TwistFunct(Epsilon)))
# Instantiate class to set up a generic airfoil with these basic parameters
Af = primitives.Airfoil(LEPoint, AirfoilChordLength, DihedralFunct(Epsilon)\
, TwistFunct(Epsilon),
EnforceSharpTE = True)
SmoothingPasses = 1
# Add NACA2212 airfoil curve to document and retrieve handles to it and
# its chord
# MaxCamberPercChord = 2, MaxCamberLocTenthChord = 2,
# MaxThicknessPercChord = 12
# Airf,Chrd = primitives.Airfoil.AddNACA4(Af, 2*(1-Epsilon), 2, 10,
# SmoothingPasses)
Airf,Chrd = primitives.Airfoil.AddNACA4(Af, 0, 2, 12, SmoothingPasses)
# Airf,Chrd = primitives.Airfoil.AddNACA4(Af, 0, 0, 12, SmoothingPasses)
return Airf, Chrd
def mySweepAngleFunctionTailplane(Epsilon):
# User-defined function describing the variation of sweep angle as a fn
# of the leading edge coordinate
return 0
def myDihedralFunctionTailplane(Epsilon):
# User-defined function describing the variation of dihedral as a function
# of the leading edge coordinate
return 0
#========= END OF TAILPLANE ==================================================
#======== TAILFIN ============================================================
def myTwistFunctionFin(Epsilon):
# User-defined function describing the variation of twist as a function
# of the leading edge coordinate
return 0
def myChordFunctionFin(Epsilon):
# User-defined function describing the variation of chord as a function of
# the leading edge coordinate
return 1
def myAirfoilFunctionFin(Epsilon, LEPoint, ChordFunct, ChordFactor,\
DihedralFunct, TwistFunct):
# Defines the variation of cross section as a function of Epsilon
AirfoilChordLength = (ChordFactor*ChordFunct(Epsilon))/math.cos(\
math.radians(TwistFunct(Epsilon)))
# Instantiate class to set up a generic airfoil with these basic parameters
Af = primitives.Airfoil(LEPoint, AirfoilChordLength, DihedralFunct(Epsilon)\
, TwistFunct(Epsilon),
EnforceSharpTE = True)
SmoothingPasses = 1
# Add NACA2212 airfoil curve to document and retrieve handles to it and
# its chord
# MaxCamberPercChord = 2, MaxCamberLocTenthChord = 2,
# MaxThicknessPercChord = 12
Airf,Chrd = primitives.Airfoil.AddNACA4(Af, 0, 2, 12, SmoothingPasses)
# Airf,Chrd = primitives.Airfoil.AddNACA4(Af, 0, 0, 12, SmoothingPasses)
return Airf, Chrd
def mySweepAngleFunctionFin(Epsilon):
# User-defined function describing the variation of sweep angle as a fn
# of the leading edge coordinate
return 0
def myDihedralFunctionFin(Epsilon):
# User-defined function describing the variation of dihedral as a function
# of the leading edge coordinate
return 0
#========= END OF TAILFIN ====================================================
#========= START OF POD ======================================================
def pod(Location, Length, Fineness, CylFraction, Axis = None, Twist = 0):
CylLength = Length*CylFraction
AirfoilLength = Length*(1-CylFraction)
Af = primitives.Airfoil(Location, AirfoilLength, 0, Twist,\
EnforceSharpTE = True)
SmoothingPasses = 2
Airf,Chrd = primitives.Airfoil.AddNACA4(Af, 0, 0,\
Fineness*(1/(1-CylFraction)), SmoothingPasses)
LEPoint = rs.CurveStartPoint(Chrd)
LEPointParameter = rs.CurveClosestPoint(Airf, LEPoint)
[Airf1,Airf2] = rs.SplitCurve(Airf, LEPointParameter)
rs.DeleteObject(Airf2)
Airf = Airf1
if CylFraction>0:
AP1 = rs.AddPoint([Location[0]+0.3*AirfoilLength, Location[1],\
Location[2]+AirfoilLength])
SplitPointParameter = rs.CurveClosestPoint(Airf1, AP1)
[AirfAFT, AirfFWD] = rs.SplitCurve(Airf1, SplitPointParameter)
rs.MoveObject(AirfAFT, [CylLength, 0,0])
FWDPoint = rs.CurveStartPoint(AirfFWD)
AFTPoint = rs.CurveEndPoint(AirfAFT)
Connector = rs.AddLine(FWDPoint, AFTPoint)
Airf = rs.JoinCurves([AirfFWD,Connector,AirfAFT], True)
rs.DeleteObjects([Connector, AP1])
if Axis:
PodSurf = rs.AddRevSrf(Airf, Axis, 0, 360)
else:
PodSurf = rs.AddRevSrf(Airf, Chrd, 0, 360)
rs.DeleteObjects([Airf2, Chrd, Airf])
return [PodSurf]
#========= END OF POD ======================================================
#========= LANDING GEAR
def AddTorusXY(CentreP, MajorRadius, MinorRadius):
CpX = CentreP[0]
CpY = CentreP[1]
CpZ = CentreP[2]
C1 = [CpX+MajorRadius-MinorRadius, CpY, CpZ]
C2 = [CpX+MajorRadius+MinorRadius, CpY, CpZ]
C3 = [CpX+MajorRadius , CpY, CpZ+MinorRadius]
C = rs.AddCircle3Pt(C1, C2, C3)
RevAx = rs.AddLine(CentreP, [CpX, CpY, CpZ + 1])
Torus = rs.AddRevSrf(C, RevAx)
rs.DeleteObjects([C, RevAx])
return Torus
def LandingGear(WheelCentre, WheelRadius, StrutLength):
TyreDepth = 0.5*WheelRadius
Tyre = AddTorusXY(WheelCentre, WheelRadius-0.5*TyreDepth, TyreDepth*0.5)
DiskThickness = 0.05*WheelRadius
DiskBaseCentre = [WheelCentre[0], WheelCentre[1],\
WheelCentre[2]+DiskThickness*0.5]
DiskTopCentre = [WheelCentre[0], WheelCentre[1],\
WheelCentre[2]-DiskThickness*0.5]
AxleTopCentre = [WheelCentre[0], WheelCentre[1],\
WheelCentre[2]+DiskThickness*0.5+TyreDepth]
Disk = rs.AddCylinder(DiskBaseCentre, DiskTopCentre,\
WheelRadius-0.5*TyreDepth, True)
Axle = rs.AddCylinder(DiskTopCentre, AxleTopCentre, WheelRadius*0.1, True)
StrutEndTopCentre = [WheelCentre[0], WheelCentre[1],\
WheelCentre[2]+DiskThickness*0.5+TyreDepth+DiskThickness]
StrutWidth = WheelRadius*0.5
StrutThickness = DiskThickness
StrutEnd = rs.AddCylinder(AxleTopCentre, StrutEndTopCentre, StrutWidth,True)
vB = []
list.append(vB, [ AxleTopCentre[0]-StrutWidth,\
AxleTopCentre[1], AxleTopCentre[2]])
list.append(vB, [ AxleTopCentre[0]+StrutWidth,\
AxleTopCentre[1], AxleTopCentre[2]])
list.append(vB, [ AxleTopCentre[0]+StrutWidth,\
AxleTopCentre[1]+StrutLength, AxleTopCentre[2]])
list.append(vB, [ AxleTopCentre[0]-StrutWidth,\
AxleTopCentre[1]+StrutLength, AxleTopCentre[2]])
list.append(vB, [ AxleTopCentre[0]-StrutWidth,\
AxleTopCentre[1], AxleTopCentre[2]+StrutThickness])
list.append(vB, [ AxleTopCentre[0]+StrutWidth,\
AxleTopCentre[1], AxleTopCentre[2]+StrutThickness])
list.append(vB, [ AxleTopCentre[0]+StrutWidth,\
AxleTopCentre[1]+StrutLength, AxleTopCentre[2]+StrutThickness])
list.append(vB, [ AxleTopCentre[0]-StrutWidth,\
AxleTopCentre[1]+StrutLength, AxleTopCentre[2]+StrutThickness])
Strut = rs.AddBox(vB)
LG = rs.BooleanUnion([Strut, StrutEnd, Axle, Disk, Tyre])
RVec = rs.VectorCreate(WheelCentre, [WheelCentre[0]+1, WheelCentre[1],\
WheelCentre[2]])
LG = rs.RotateObject(LG, WheelCentre, -90, axis = RVec)
return LG
#========= END OF LANDING GEAR
#========= BOOLEAN SPLIT TOOLS
def BooleanSplitY(yposn,cuttersize,solid):
# take the incoming solid and split it into two new solids using a Yplane
# cutting surface at yposn
# deletes the original solid
pt1 = rs.AddPoint((-cuttersize,yposn,cuttersize))
pt2 = rs.AddPoint((-cuttersize,yposn,-cuttersize))
pt3 = rs.AddPoint((-cuttersize,yposn+cuttersize,-cuttersize))
pt4 = rs.AddPoint((-cuttersize,yposn+cuttersize,cuttersize))
pt5 = rs.AddPoint((cuttersize,yposn,cuttersize))
pt6 = rs.AddPoint((cuttersize,yposn,-cuttersize))
pt7 = rs.AddPoint((cuttersize,yposn+cuttersize,-cuttersize))
pt8 = rs.AddPoint((cuttersize,yposn+cuttersize,cuttersize))
pt9 = rs.AddPoint((-cuttersize,yposn-cuttersize,cuttersize))
pt10 = rs.AddPoint((-cuttersize,yposn-cuttersize,-cuttersize))
pt11 = rs.AddPoint((cuttersize,yposn-cuttersize,cuttersize))
pt12 = rs.AddPoint((cuttersize,yposn-cuttersize,-cuttersize))
Cutter1 = rs.AddBox([pt1, pt2, pt3, pt4, pt5, pt6, pt7, pt8])
#Cutter2 = rs.AddBox([pt1, pt2, pt9, pt10, pt5, pt6, pt11, pt12])
Cutter2 = rs.AddBox([pt1, pt2, pt10, pt9, pt5, pt6, pt12, pt11])
solid1 = rs.CopyObject(solid)
solid2 = rs.CopyObject(solid)
solid1 = rs.BooleanDifference(solid1,Cutter1)
solid2 = rs.BooleanDifference(solid2,Cutter2)
rs.DeleteObjects([pt1, pt2, pt3, pt4, pt5, pt6, pt7, pt8, pt9, pt10,\
pt11, pt12, solid])
return solid1, solid2
def BooleanSplitX(xposn,cuttersize,solid):
# take the incoming solid and split it into two new solids using a Xplane
# cutting surface at xposn
# deletes the original solid
pt1 = rs.AddPoint((xposn,-cuttersize,-cuttersize))
pt2 = rs.AddPoint((xposn+cuttersize,-cuttersize,-cuttersize))
pt3 = rs.AddPoint((xposn+cuttersize,-cuttersize,cuttersize))
pt4 = rs.AddPoint((xposn,-cuttersize,cuttersize))
pt5 = rs.AddPoint((xposn,cuttersize,-cuttersize))
pt6 = rs.AddPoint((xposn+cuttersize,cuttersize,-cuttersize))
pt7 = rs.AddPoint((xposn+cuttersize,cuttersize,cuttersize))
pt8 = rs.AddPoint((xposn,cuttersize,cuttersize))
pt9 = rs.AddPoint((xposn-cuttersize,-cuttersize,-cuttersize))
pt10 = rs.AddPoint((xposn-cuttersize,-cuttersize,cuttersize))
pt11 = rs.AddPoint((xposn-cuttersize,cuttersize,-cuttersize))
pt12 = rs.AddPoint((xposn-cuttersize,cuttersize,cuttersize))
Cutter1 = rs.AddBox([pt1, pt2, pt3, pt4, pt5, pt6, pt7, pt8])
Cutter2 = rs.AddBox([pt1, pt9, pt10, pt4, pt5, pt11, pt12, pt8])
solid1 = rs.CopyObject(solid)
solid2 = rs.CopyObject(solid)
solid1 = rs.BooleanDifference(solid1,Cutter1)
solid2 = rs.BooleanDifference(solid2,Cutter2)
rs.DeleteObjects([pt1, pt2, pt3, pt4, pt5, pt6, pt7, pt8, pt9, pt10,\
pt11, pt12, solid])
return solid1, solid2
def BooleanSplitZ(zposn,cuttersize,solid):
# take the incoming solid and split it into two new solids using a Zplane
# cutting surface at zposn
# deletes the original solid
pt1 = rs.AddPoint((-cuttersize,-cuttersize,zposn))
pt2 = rs.AddPoint((-cuttersize,-cuttersize,zposn+cuttersize))
pt3 = rs.AddPoint((-cuttersize,cuttersize,zposn+cuttersize))
pt4 = rs.AddPoint((-cuttersize,cuttersize,zposn))
pt5 = rs.AddPoint((cuttersize,-cuttersize,zposn))
pt6 = rs.AddPoint((cuttersize,-cuttersize,zposn+cuttersize))
pt7 = rs.AddPoint((cuttersize,cuttersize,zposn+cuttersize))
pt8 = rs.AddPoint((cuttersize,cuttersize,zposn))
pt9 = rs.AddPoint((-cuttersize,-cuttersize,zposn-cuttersize))
pt10 = rs.AddPoint((-cuttersize,cuttersize,zposn-cuttersize))
pt11 = rs.AddPoint((cuttersize,-cuttersize,zposn-cuttersize))
pt12 = rs.AddPoint((cuttersize,cuttersize,zposn-cuttersize))
Cutter1 = rs.AddBox([pt1, pt2, pt3, pt4, pt5, pt6, pt7, pt8])
Cutter2 = rs.AddBox([pt1, pt9, pt10, pt4, pt5, pt11, pt12, pt8])
solid1 = rs.CopyObject(solid)
solid2 = rs.CopyObject(solid)
solid1 = rs.BooleanDifference(solid1,Cutter1)
solid2 = rs.BooleanDifference(solid2,Cutter2)
rs.DeleteObjects([pt1, pt2, pt3, pt4, pt5, pt6, pt7, pt8, pt9, pt10,\
pt11, pt12, solid])
return solid1, solid2
def CutCylinder(x1,y1,z1,x2,y2,z2,diameter,Solid):
# take the incoming solid and cut a cylinder in it between the two points
# of given diameter
# preserves the original solid
pt1 = rs.AddPoint((x1,y1,z1))
pt2 = rs.AddPoint((x2,y2,z2))
Cutter = rs.AddCylinder(pt1, pt2, diameter/2)
rs.DeleteObjects([pt1, pt2])
Solid = rs.BooleanDifference(Solid,Cutter)
return Solid
def CreateSpar(x1,y1,z1,x2,y2,z2,Odiameter, Idiameter):
# take the incoming solid and cut a cylinder in it between the two points
# of given diameter
# preserves the original solid
pt1 = rs.AddPoint((x1,y1,z1))
pt2 = rs.AddPoint((x2,y2,z2))
Cutter = rs.AddCylinder(pt1, pt2, Idiameter/2)
Solid = rs.AddCylinder(pt1, pt2, Odiameter/2)
rs.DeleteObjects([pt1, pt2])
Solid = rs.BooleanDifference(Solid,Cutter)
return Solid
#========= END OF BOOLEAN SPLIT TOOLS =========================================
#========= DRAW GEOMETRY ======================================================
# first open file for writing harpoon meshing instructions
#
fo = open("C:\\Users\\Andy\\Documents\\airconicsv021\\harpoon_meshing_file.cfg", "w")
harpoonData(fo, "C:\\Users\\Andy\\Documents\\ajk\\UAV design\\Decode2.stl",\
DesiredyPlus, Chord/1000.0, rho_C, V_L, Visc_C, RefLev, FirstCellHtMult)
rs.EnableRedraw(False)
SWEEP_QTR_rad = math.radians(SWEEP_QTR_deg)
SWEEP_LE_rad = math.atan(math.tan(SWEEP_QTR_rad)+(1/AR)*(1-TaperRatio)/(1+TaperRatio))
SWEEP_LE_deg = math.degrees(SWEEP_LE_rad)
# Wing apex location
P = (0,0,0)
LooseSurf = 3
SegmentNo = 100
SettingAngle = 2.53 # as computed with XFLR5 to give Cl of 0.28 at 30 m/s
TipRequired = 1
SectionsRequired = True # when optimizing this currently needs to be False but
# when creating XFLR5 files it must be True
#SegmentNo = 10 # reduce segment number when optimizing to speed up process
Wing = liftingsurface.LiftingSurface(P, mySweepAngleFunctionTractor,\
myDihedralFunctionTractor, myTwistFunctionTractor, myChordFunctionTractor,\
myAirfoilFunctionTractor, LooseSurf, SegmentNo, TipRequired, SectionsRequired)
#Wing = liftingsurface.LiftingSurface(P, mySweepAngleFunctionTractor,\
#myDihedralFunctionTractor, myTwistFunctionTractor, myChordFunctionTractor,\
#myAirfoilFunctionTractor, LooseSurf, SegmentNo)
# Specify the desired aspect ratio, span, etc
Wing.TargetAspectRatio = AR
Wing.TargetArea = Awing/1000000.0
Wing.wTargetAspectRatio = 1
Wing.wTargetArea = 1
ChordFactor = 0.2293
ScaleFactor = 1.9905
OptimizeChordScale=0
#SLS, ActualSemiSpan, LSP_area, RootChord, AR, SWingTip =\
#Wing.GenerateLiftingSurface(ChordFactor, ScaleFactor, OptimizeChordScale)
SLS, ActualSemiSpan, LSP_area, RootChord, AR, SWingTip, Sections =\
Wing.GenerateLiftingSurface(ChordFactor, ScaleFactor, OptimizeChordScale)
print "Wing.Scalefactor, ScaleFactor =",Wing.ScaleFactor,ScaleFactor
print "Wing.Chordfactor, ChordFactor =",Wing.ChordFactor,ChordFactor
TipX = math.tan( SWEEP_LE_rad ) * ActualSemiSpan
RotVec = rs.VectorCreate((0,0,0),(0,1,0))
SLS = rs.RotateObject(SLS, (0,0,0), -SettingAngle, axis = RotVec)
SWingTip = rs.RotateObject(SWingTip, (0,0,0), -SettingAngle, axis = RotVec)
SLS_TE = ExtractTrailingEdge(SLS)
# shift wing up to allow for setting angle about LE and not 1/4 chord point where we attach it
SLS = rs.MoveObject(SLS,(0.0, 0.0, 0.25*RootChord*math.sin(math.radians(SettingAngle))))
SWingTip = rs.MoveObject(SWingTip,(0.0, 0.0, 0.25*RootChord*math.sin(math.radians(SettingAngle))))
SLS_TE = rs.MoveObject(SLS_TE,(0.0, 0.0, 0.25*RootChord*math.sin(math.radians(SettingAngle))))
if Ailerons:
SLScopy=rs.CopyObject(SLS)
Aflapconfig1 = ['simpleflap', ASpanStart, ASpanEnd, AChord, ATaper, ADeflectionAngle]
Devices = [Aflapconfig1]
SAileron, Area, Cutter, Cutter1, Cutter2, CutBrick = HLD.AddHighLiftDevices(SLS, Devices)
rs.DeleteObjects([Cutter, Cutter1, Cutter2])
SLS = rs.BooleanDifference(SLS,CutBrick)
PLS = act.MirrorObjectXZ(SLS)
PAileron = act.MirrorObjectXZ(SAileron)
rs.DeleteObjects([SLS, SAileron])
Aflapconfig1 = ['simpleflap', ASpanStart, ASpanEnd, AChord, ATaper, -ADeflectionAngle]
Devices = [Aflapconfig1]
SAileron, Area, Cutter, Cutter1, Cutter2, CutBrick = HLD.AddHighLiftDevices(SLScopy, Devices)
rs.DeleteObjects([Cutter, Cutter1, Cutter2])
SLS = rs.BooleanDifference(SLScopy,CutBrick)
rs.DeleteObjects([SLScopy])
else:
PLS = act.MirrorObjectXZ(SLS)
PWingTip = act.MirrorObjectXZ(SWingTip)
SLS_TE_Wake_Curve = rs.OffsetCurve( SLS_TE, [1.0,0.0,0.0],Chord/6000)
SLS_TE_Surf = rs.AddEdgeSrf([SLS_TE, SLS_TE_Wake_Curve])
PLS_TE_Surf = act.MirrorObjectXZ(SLS_TE_Surf)
TE_Surf= rs.BooleanUnion([SLS_TE_Surf, PLS_TE_Surf])
DivPts = rs.DivideCurve(SLS_TE,SegmentNo)
rs.DeleteObjects([SLS_TE, SLS_TE_Wake_Curve])
#for ii in range(0, SegmentNo):
# harpoonRefZone(fo, [DivPts[ii].X, DivPts[ii].Y, DivPts[ii].Z], [DivPts[ii+1].X,\
# DivPts[ii+1].Y, DivPts[ii+1].Z], RefLev, 0.2, 0.0075, 14.0, 4.0)
# harpoonRefZone(fo, [DivPts[ii].X, -DivPts[ii].Y, DivPts[ii].Z], [DivPts[ii+1].X,\
# -DivPts[ii+1].Y, DivPts[ii+1].Z], RefLev, 0.2, 0.0075, 14.0, 4.0)
if Ailerons:
Zset = Chord / 1000.0 * AChord * math.sin(math.radians(SettingAngle))
for ii in range(int(ASpanStart*SegmentNo)-1, int(ASpanEnd*SegmentNo)+1):
harpoonRefZone(fo, [DivPts[ii].X-(AChord+0.01)*Chord*\
myChordFunctionTractor(ii/SegmentNo)/1000.0,\
DivPts[ii].Y, DivPts[ii].Z+Zset], [DivPts[ii+1].X-(AChord+0.01)*Chord*\
myChordFunctionTractor(ii/SegmentNo)/1000.0,\
DivPts[ii+1].Y, DivPts[ii+1].Z+Zset], RefLev+4, 0.04*Chord/1000.0, 0.03, 0.0, 0.0)
harpoonRefZone(fo, [DivPts[ii].X-(AChord+0.01)*Chord*\
myChordFunctionTractor(ii/SegmentNo)/1000.0,\
-DivPts[ii].Y, DivPts[ii].Z+Zset], [DivPts[ii+1].X-(AChord+0.01)*Chord*\
myChordFunctionTractor(ii/SegmentNo)/1000.0,\
-DivPts[ii+1].Y, DivPts[ii+1].Z+Zset], RefLev+4, 0.04*Chord/1000.0, 0.03, 0.0, 0.0)
harpoonRefZone(fo, [TipX, DivPts[SegmentNo].Y*0.985, DivPts[SegmentNo].Z],\
[TipX, DivPts[SegmentNo].Y*1.015, DivPts[SegmentNo].Z], RefLev,\
RootChord*TaperRatio*3.0, 0.05, 14.0, 4.0)
harpoonRefZone(fo, [TipX, -DivPts[SegmentNo].Y*0.985, DivPts[SegmentNo].Z],\
[TipX, -DivPts[SegmentNo].Y*1.015, DivPts[SegmentNo].Z], RefLev,\
RootChord*TaperRatio*3.0, 0.05, 14.0, 4.0)
# ===== Booms =============================================================
PodLength = 1.5*Chord/1000.0
BoomLength = -x_tail_spar/1000.0
BoomY = y_tail_boom/1000.0
BoomZ = z_tail_boom/1000.0
[SPodSurf] = pod([0.025*PodLength,BoomY,BoomZ],PodLength,11, 0.1)
if CutStructure:
SPodSurf = CutCylinder(RootChord/4.0,BoomY,BoomZ, BoomLength,BoomY,BoomZ,BoomODia,SPodSurf)
SBoom = CreateSpar(RootChord/4.0+MainSparODia/2.0,BoomY,BoomZ,\
BoomLength-TailSparODia/2.0,BoomY,BoomZ, BoomODia-SparClearance, BoomIDia)
else:
SBoom = rs.AddCylinder([RootChord/4.0,BoomY,BoomZ], [BoomLength,BoomY,BoomZ], 0.01)
PPodSurf = act.MirrorObjectXZ(SPodSurf)
PBoom = act.MirrorObjectXZ(SBoom)
if CutStructure: # cut booms to enable biased meshing along their lengths away
# from where the pod ends
SBoom, SBoom1 = BooleanSplitX(0.875*PodLength,CutterSize,SBoom)
PBoom, PBoom1 = BooleanSplitX(0.875*PodLength,CutterSize,PBoom)
# ===== Tailplane =============================================================
TailChord = Chord_tail/1000.0
FinX = -x_tail_spar/1000.0-TailChord/4.0
P_TP = [FinX,0,0]
LooseSurf_TP = 1
SegmentNo_TP = 100
TipRequired_TP = 1
SectionsRequired_TP = True # when optimizing this currently needs to be False
# but when creating XFLR5 files it must be True
#SegmentNo = 10 # reduce segment number when optimizing to speed up process
Tailplane = liftingsurface.LiftingSurface(P_TP, mySweepAngleFunctionTailplane,\
myDihedralFunctionTailplane, myTwistFunctionTailplane, myChordFunctionTailplane,\
myAirfoilFunctionTailplane, LooseSurf_TP, SegmentNo_TP, TipRequired_TP, SectionsRequired_TP)
#Tailplane = liftingsurface.LiftingSurface(P_TP, mySweepAngleFunctionTailplane,\
#myDihedralFunctionTailplane, myTwistFunctionTailplane, myChordFunctionTailplane,\
#myAirfoilFunctionTailplane, LooseSurf_TP, SegmentNo_TP)
if VTail: # we will use a pair of tails rotated to make the V tail so
# allow for this in area and aspect ratio
CantAngle = math.atan((2*Height_fin)/Span_tail)
TailSpan = Span_tail/1000.0/math.cos(CantAngle)/2.0
Tailplane.TargetAspectRatio = ARtail/math.cos(CantAngle)/2.0
Tailplane.TargetArea = Atail/1000000.0/math.cos(CantAngle)/2.0
else:
CantAngle=0.0
TailSpan = Span_tail/1000.0
Tailplane.TargetAspectRatio = ARtail
Tailplane.TargetArea = Atail/1000000.0
Tailplane.wTargetAspectRatio = 1
Tailplane.wTargetArea = 1
ChordFactor_TP = 0.78515229764
ScaleFactor_TP = 0.2536478226
OptimizeChordScale_TP=0
#SLS_TP, ActualSemiSpan_TP, LSP_area_TP, RootChord_TP, AR_TP, SWingTip_TP =\
#Tailplane.GenerateLiftingSurface(ChordFactor_TP, ScaleFactor_TP, OptimizeChordScale_TP)
SLS_TP, ActualSemiSpan_TP, LSP_area_TP, RootChord_TP, AR_TP, SWingTip_TP, Sections_TP =\
Tailplane.GenerateLiftingSurface(ChordFactor_TP, ScaleFactor_TP, OptimizeChordScale_TP)
print "Tailplane.Scalefactor, ScaleFactor =",Tailplane.ScaleFactor,ScaleFactor_TP
print "Tailplane.Chordfactor, ChordFactor =",Tailplane.ChordFactor,ChordFactor_TP
SLS_TP_TE = ExtractTrailingEdge(SLS_TP)
if Elevators:
Eflapconfig = ['simpleflap', ESpanStart, ESpanEnd, EChord, ETaper, EDeflectionAngle]
Devices = [Eflapconfig]
SElevator, Area, Cutter, Cutter1, Cutter2, CutBrick = HLD.AddHighLiftDevices(SLS_TP, Devices)
rs.DeleteObjects([Cutter, Cutter1, Cutter2])
SLS_TP = rs.BooleanDifference(SLS_TP,CutBrick)
# shift elevator down to allow for setting angle about LE and not 1/4 chord
# point where we attach it
SElevator = rs.MoveObject(SElevator,(0.0, 0.0, -0.25*RootChord_TP*math.sin\
(math.radians(myTwistFunctionTailplane(0.0)))))
PElevator = act.MirrorObjectXZ(SElevator)
STail = rs.JoinSurfaces([SLS_TP,SWingTip_TP])
rs.DeleteObjects([SLS_TP,SWingTip_TP])
PTail = act.MirrorObjectXZ(STail)
Tail = rs.JoinSurfaces([STail, PTail])
rs.DeleteObjects([STail, PTail])
# shift tail down to allow for setting angle about LE and not 1/4 chord point where we attach it
Tail = rs.MoveObject(Tail,(0.0, 0.0, -0.25*RootChord_TP*math.sin\
(math.radians(myTwistFunctionTailplane(0.0)))))
SLS_TP_TE = rs.MoveObject(SLS_TP_TE,(0.0, 0.0, -0.25*RootChord_TP*math.sin\
(math.radians(myTwistFunctionTailplane(0.0)))))
if VTail:
RotVec = rs.VectorCreate([FinX,y_tail_boom/1000.0,0],[FinX+1,y_tail_boom/1000.0,0])
RotCent = [FinX,y_tail_boom/1000.0,0]
if CutStructure:
#Tail = rs.BooleanUnion([Tail, SFin, PFin])
Tail = CutCylinder(BoomLength,-ActualSemiSpan_TP,BoomZ, BoomLength,\
ActualSemiSpan_TP,BoomZ,TailSparODia,Tail)
TailSpar = CreateSpar(BoomLength,-ActualSemiSpan_TP,BoomZ, BoomLength,\
ActualSemiSpan_TP,BoomZ, TailSparODia-SparClearance, TailSparIDia)
Tail, TailS1 = BooleanSplitY(BoomY-(y_tail_boom/1000.0*(1.0-1.0/math.cos\
(CantAngle))+ActualSemiSpan_TP)+0.05*Chord/1000.0,CutterSize,Tail)
Tail, TailS2 = BooleanSplitY(BoomY-(y_tail_boom/1000.0*(1.0-1.0/math.cos\
(CantAngle))+ActualSemiSpan_TP)-0.05*Chord/1000.0,CutterSize,Tail)
Tail, TailS3 = BooleanSplitY(ESpanStart*ActualSemiSpan_TP+0.00175,CutterSize,Tail)
TailS1, TailS4 = BooleanSplitY(ESpanEnd*ActualSemiSpan_TP-0.00075,CutterSize,TailS1)
Tail, TailS5 = BooleanSplitY(-ESpanStart*ActualSemiSpan_TP-0.00175,CutterSize,Tail)
Tail, TailS6 = BooleanSplitY(-ESpanEnd*ActualSemiSpan_TP+0.00075,CutterSize,Tail)
SLS_TP_TE_P = act.MirrorObjectXZ(SLS_TP_TE)
SLS_TP_TE_S = rs.CopyObject(SLS_TP_TE)
rs.DeleteObjects([SLS_TP_TE])
SLS_TP_TE = rs.JoinCurves([SLS_TP_TE_S, SLS_TP_TE_P])
rs.DeleteObjects([SLS_TP_TE_S, SLS_TP_TE_P])
Tail = rs.MoveObject(Tail, [0,y_tail_boom/1000.0*(1.0-1.0/math.cos(CantAngle))+ActualSemiSpan_TP,0])
SLS_TP_TE = rs.MoveObject(SLS_TP_TE, [0,y_tail_boom/1000.0*\
(1.0-1.0/math.cos(CantAngle))+ActualSemiSpan_TP,0])
Tail = rs.RotateObject(Tail,RotCent,math.degrees(CantAngle), axis = RotVec)
SLS_TP_TE = rs.RotateObject(SLS_TP_TE,RotCent,math.degrees(CantAngle), axis = RotVec)
TailP = act.MirrorObjectXZ(Tail)
CentrePod = pod([FinX, 0, y_tail_boom/1000.0*math.tan(CantAngle)],RootChord_TP,12, 0.0)
if CutStructure:
ypos1=y_tail_boom/1000.0*(1.0-1.0/math.cos(CantAngle))+ActualSemiSpan_TP
TailS1 = rs.MoveObject(TailS1, [0,ypos1,0])
TailS2 = rs.MoveObject(TailS2, [0,ypos1,0])
TailS3 = rs.MoveObject(TailS3, [0,ypos1,0])
TailS4 = rs.MoveObject(TailS4, [0,ypos1,0])
TailS5 = rs.MoveObject(TailS5, [0,ypos1,0])
TailS6 = rs.MoveObject(TailS6, [0,ypos1,0])
TailSpar = rs.MoveObject(TailSpar, [0,ypos1,0])
TailS1 = rs.RotateObject(TailS1,RotCent,math.degrees(CantAngle), axis = RotVec)
TailS2 = rs.RotateObject(TailS2,RotCent,math.degrees(CantAngle), axis = RotVec)
TailS3 = rs.RotateObject(TailS3,RotCent,math.degrees(CantAngle), axis = RotVec)
TailS4 = rs.RotateObject(TailS4,RotCent,math.degrees(CantAngle), axis = RotVec)
TailS5 = rs.RotateObject(TailS5,RotCent,math.degrees(CantAngle), axis = RotVec)
TailS6 = rs.RotateObject(TailS6,RotCent,math.degrees(CantAngle), axis = RotVec)
TailSpar = rs.RotateObject(TailSpar,RotCent,math.degrees(CantAngle), axis = RotVec)
TailS2 = CutCylinder(0.25*Chord/1000.0,BoomY,BoomZ, BoomLength,BoomY,BoomZ,BoomODia,TailS2)
TailP1 = act.MirrorObjectXZ(TailS1)
TailP2 = act.MirrorObjectXZ(TailS2)
TailP3 = act.MirrorObjectXZ(TailS3)
TailP4 = act.MirrorObjectXZ(TailS4)
TailP5 = act.MirrorObjectXZ(TailS5)
TailP6 = act.MirrorObjectXZ(TailS6)
TailPSpar = act.MirrorObjectXZ(TailSpar)
Tail = rs.BooleanUnion([Tail, TailP])
if Elevators:
SElevator = rs.MoveObject(SElevator, [0,y_tail_boom/1000.0*\
(1.0-1.0/math.cos(CantAngle))+ActualSemiSpan_TP,0])
PElevator = rs.MoveObject(PElevator, [0,y_tail_boom/1000.0*\
(1.0-1.0/math.cos(CantAngle))+ActualSemiSpan_TP,0])
SElevator = rs.RotateObject(SElevator,RotCent,math.degrees(CantAngle), axis = RotVec)
PElevator = rs.RotateObject(PElevator,RotCent,math.degrees(CantAngle), axis = RotVec)
SElevatorP = act.MirrorObjectXZ(SElevator)
PElevatorP = act.MirrorObjectXZ(PElevator)
#SLS_TP_TE_Wake_Curve = rs.OffsetCurve( SLS_TP_TE, [1.0,0.0,0.0],Chord/6000)
SLS_TP_TE_Wake_Curve = rs.CopyObject( SLS_TP_TE, [Chord/6000,0.0,0.0])
SLS_TP_TE_Surf = rs.AddEdgeSrf([SLS_TP_TE, SLS_TP_TE_Wake_Curve])
PLS_TP_TE_Surf = act.MirrorObjectXZ(SLS_TP_TE_Surf)
#TP_TE_Surf= rs.BooleanUnion([SLS_TP_TE_Surf, PLS_TP_TE_Surf])
DivPts_TP = rs.DivideCurve(SLS_TP_TE,SegmentNo_TP)
rs.DeleteObjects([SLS_TP_TE, SLS_TP_TE_Wake_Curve])
#for ii in range(0, SegmentNo_TP):
# harpoonRefZone(fo, [DivPts_TP[ii].X, DivPts_TP[ii].Y, DivPts_TP[ii].Z],\
# [DivPts_TP[ii+1].X, DivPts_TP[ii+1].Y, DivPts_TP[ii+1].Z], RefLev, 0.2, 0.015, 14.0, 4.0)
# harpoonRefZone(fo, [DivPts_TP[ii].X, -DivPts_TP[ii].Y, DivPts_TP[ii].Z],\
# [DivPts_TP[ii+1].X, -DivPts_TP[ii+1].Y, DivPts_TP[ii+1].Z], RefLev, 0.2, 0.015, 14.0, 4.0)
if Elevators:
Zset = RootChord_TP * EChord * math.sin(math.radians(myTwistFunctionTailplane(1.0)))
for ii in range(int(ESpanStart*SegmentNo_TP)-1, int(ESpanEnd*SegmentNo_TP)+1):
harpoonRefZone(fo, [DivPts_TP[ii].X-(EChord-0.03)*RootChord_TP*\
myChordFunctionTailplane(ii/SegmentNo_TP), DivPts_TP[ii].Y, DivPts_TP[ii].Z - Zset],\
[DivPts_TP[ii+1].X-(EChord-0.03)*RootChord_TP*myChordFunctionTailplane(ii/SegmentNo_TP),\
DivPts_TP[ii+1].Y, DivPts_TP[ii+1].Z - Zset], RefLev+4, 0.04*RootChord_TP, 0.02, 0.0, 0.0)
harpoonRefZone(fo, [DivPts_TP[ii].X-(EChord-0.03)*RootChord_TP*\
myChordFunctionTailplane(ii/SegmentNo_TP), -DivPts_TP[ii].Y, DivPts_TP[ii].Z - Zset], \
[DivPts_TP[ii+1].X-(EChord-0.03)*RootChord_TP*myChordFunctionTailplane(ii/SegmentNo_TP),\
-DivPts_TP[ii+1].Y, DivPts_TP[ii+1].Z - Zset], RefLev+4, 0.04*RootChord_TP, 0.02, 0.0, 0.0)
harpoonRefZone(fo, [FinX, DivPts_TP[SegmentNo_TP].Y*0.985, DivPts_TP[SegmentNo_TP].Z],\
[FinX, DivPts_TP[SegmentNo_TP].Y*1.015, DivPts_TP[SegmentNo_TP].Z], RefLev-1,\
RootChord_TP*3.0, 0.03, 14.0, 4.0)
harpoonRefZone(fo, [FinX, -DivPts_TP[SegmentNo_TP].Y*0.985, DivPts_TP[SegmentNo_TP].Z],\
[FinX, -DivPts_TP[SegmentNo_TP].Y*1.015, DivPts_TP[SegmentNo_TP].Z], RefLev-1,\
RootChord_TP*3.0, 0.03, 14.0, 4.0)
# ===== Tailfin =============================================================
if VTail == False:
P_Fin = [FinX+RootChord_TP/30.0,BoomY,0.0]
FinChord = Chord_fin/1000.0
FinSpan = Height_fin/1000.0
FinTC = 12
LooseSurf_Fin = 1
SegmentNo_Fin= 100
TipRequired_Fin = 1
SectionsRequired_Fin = True
#Fin = liftingsurface.LiftingSurface(P_Fin, mySweepAngleFunctionFin, myDihedralFunctionFin,\
#myTwistFunctionFin, myChordFunctionFin, myAirfoilFunctionFin, LooseSurf_Fin, SegmentNo_Fin)
Fin = liftingsurface.LiftingSurface(P_Fin, mySweepAngleFunctionFin, myDihedralFunctionFin,\
myTwistFunctionFin, myChordFunctionFin, myAirfoilFunctionFin, LooseSurf_Fin, SegmentNo_Fin,\
TipRequired_Fin, SectionsRequired_Fin)
# Specify the desired aspect ratio and span
Fin.TargetAspectRatio = Height_fin*2/Chord_fin
Fin.TargetArea = Chord_fin*Height_fin/1000000.0
Fin.wTargetAspectRatio = 1
Fin.wTargetArea = 1
ChordFactor_Fin = 0.658
ScaleFactor_Fin = 0.208
OptimizeChordScale_Fin=0
SLS_Fin, ActualSemiSpan_Fin, LSP_area_Fin, RootChord_Fin, AR_Fin, SWingTip_Fin, Sections_Fin =\
Fin.GenerateLiftingSurface(ChordFactor_Fin, ScaleFactor_Fin, OptimizeChordScale_Fin)
#SLS_Fin, ActualSemiSpan_Fin, LSP_area_Fin, RootChord_Fin, AR_Fin, SWingTip_Fin =\
#Fin.GenerateLiftingSurface(ChordFactor_Fin, ScaleFactor_Fin, OptimizeChordScale_Fin)
print "Fin.Scalefactor, ScaleFactor =",Fin.ScaleFactor,ScaleFactor_Fin
print "Fin.Chordfactor, ChordFactor =",Fin.ChordFactor,ChordFactor_Fin
SLS_Fin_TE = ExtractTrailingEdge(SLS_Fin)
if Rudder:
Rflapconfig1 = ['simpleflap', RSpanStart, RSpanEnd, RChord, RTaper, RDeflectionAngle]
Devices = [Rflapconfig1]
SRudder, Area, Cutter, Cutter1, Cutter2, CutBrick = HLD.AddHighLiftDevices(SLS_Fin, Devices)
rs.DeleteObjects([Cutter, Cutter1, Cutter2])
SLS_Fin = rs.BooleanDifference(SLS_Fin,CutBrick)
SFin = rs.JoinSurfaces([SLS_Fin,SWingTip_Fin])
P_FinAft = [P_Fin[0]+1, P_Fin[1], P_Fin[2]]
RotVec = rs.VectorCreate(P_Fin, P_FinAft)
SFin = rs.RotateObject(SFin, P_Fin, -FinAngle, axis = RotVec)
if Rudder:
SRudder = rs.RotateObject(SRudder, P_Fin, -FinAngle, axis = RotVec)
# move fins up to prevent them poking through the bottom of an elevator with setting angle
SRudder = rs.MoveObject(SRudder, [0.0, 0.0, 0.25*RootChord_TP*math.sin(math.radians\
(myTwistFunctionTailplane(0.0)))])
PRudder = act.MirrorObjectXZ(SRudder)
# move fins up to prevent them poking through the bottom of an elevator with setting angle
SFin = rs.MoveObject(SFin, [0.0, 0.0, 0.25*RootChord_TP*math.sin(math.radians\
(myTwistFunctionTailplane(0.0)))])
rs.CapPlanarHoles(SFin)
PFin = act.MirrorObjectXZ(SFin)
SLS_Fin_TE_Wake_Curve = rs.CopyObject( SLS_Fin_TE, [Chord/6000,0.0,0.0])
SLS_Fin_TE_Surf = rs.AddEdgeSrf([SLS_Fin_TE, SLS_Fin_TE_Wake_Curve])
SLS_Fin_TE_Surf = rs.RotateObject(SLS_Fin_TE_Surf, P_Fin, -FinAngle, axis = RotVec)
# move fins up to prevent them poking through the bottom of an elevator with setting angle
SLS_Fin_TE_Surf = rs.MoveObject(SLS_Fin_TE_Surf, [0.0, 0.0, 0.25*RootChord_TP*math.sin\
(math.radians(myTwistFunctionTailplane(0.0)))])
PLS_Fin_TE_Surf = act.MirrorObjectXZ(SLS_Fin_TE_Surf)
SLS_Fin_TE = rs.RotateObject(SLS_Fin_TE, P_Fin, -FinAngle, axis = RotVec)
# move fins up to prevent them poking through the bottom of an elevator with setting angle
SLS_Fin_TE = rs.MoveObject(SLS_Fin_TE, [0.0, 0.0, 0.25*RootChord_TP*math.sin\
(math.radians(myTwistFunctionTailplane(0.0)))])
DivPts_Fin = rs.DivideCurve(SLS_Fin_TE,SegmentNo_Fin)
rs.DeleteObjects([SLS_Fin,SWingTip_Fin, SLS_Fin_TE, SLS_Fin_TE_Wake_Curve])
if Rudder:
for ii in range(int(RSpanStart*SegmentNo_Fin)-1, int(RSpanEnd*SegmentNo_Fin)+1):
harpoonRefZone(fo, [DivPts_Fin[ii].X-(RChord-0.03)*RootChord_Fin*\
myChordFunctionFin(ii/SegmentNo_Fin), DivPts_Fin[ii].Y-(RootChord_Fin*FinTC/100.0/2.0),\
DivPts_Fin[ii].Z], [DivPts_Fin[ii+1].X-(RChord-0.03)*RootChord_Fin*\
myChordFunctionFin(ii/SegmentNo_Fin), DivPts_Fin[ii+1].Y+(RootChord_Fin*FinTC/100.0/2.0),\
DivPts_Fin[ii+1].Z], RefLev+4, 0.05*RootChord_Fin, 0.02, 0.0, 0.0)
harpoonRefZone(fo, [DivPts_Fin[ii].X-(RChord-0.03)*RootChord_Fin*\
myChordFunctionFin(ii/SegmentNo_Fin), -DivPts_Fin[ii].Y-(RootChord_Fin*FinTC/100.0/2.0),\
DivPts_Fin[ii].Z], [DivPts_Fin[ii+1].X-(RChord-0.03)*RootChord_Fin*\
myChordFunctionFin(ii/SegmentNo_Fin), -DivPts_Fin[ii+1].Y+(RootChord_Fin*FinTC/100.0/2.0),\
DivPts_Fin[ii+1].Z], RefLev+4, 0.05*RootChord_Fin, 0.02, 0.0, 0.0)
# harpoonRefZone(fo, [FinX+RootChord_Fin, BoomY+0.0075, ActualSemiSpan_Fin/2],\
#[FinX+RootChord_Fin, BoomY-0.0075, ActualSemiSpan_Fin/2], RefLev, 0.2,\
#ActualSemiSpan_Fin, 14.0, 4.0)
# harpoonRefZone(fo, [FinX+RootChord_Fin, -BoomY-0.0075, ActualSemiSpan_Fin/2],\
#[FinX+RootChord_Fin, -BoomY+0.0075, ActualSemiSpan_Fin/2], RefLev, 0.2,\
#ActualSemiSpan_Fin, 14.0, 4.0)
harpoonRefZone(fo, [FinX, BoomY*0.975, ActualSemiSpan_Fin], [FinX, BoomY*1.025,\