-
Notifications
You must be signed in to change notification settings - Fork 0
/
LaunchVehicle.py
executable file
·1502 lines (1349 loc) · 132 KB
/
LaunchVehicle.py
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
# NOTES:
# Must still modify avionics and wiring estimates for small LVs
from Mission import Mission
from math import sqrt, pow, pi, floor, ceil
import pandas as pd
from pptx import Presentation
from pptx.enum.shapes import MSO_SHAPE
from pptx.enum.dml import MSO_THEME_COLOR
from pptx.dml.color import ColorFormat, RGBColor
from pptx.util import Inches
import matlab.engine
class LaunchVehicle(Mission) :
def __init__(self, name, TW, body_material, num_steps, engine_Isps, sigmas, PL, Mission):
self.name = name
self.TW = TW
self.body_material = body_material
if body_material == "Aluminum 6061-T6":
self.rho_body = 2700 # kg/m^3 al 6061-T6 density
elif body_material == "Aluminum 7075-T6":
self.rho_body = 2810 # kg/m^3 al 7075-T6 density
elif body_material == "Aluminum 2219-T87":
self.rho_body = 2840 # kg/m^3 al 7075-T6 density
self.num_steps = num_steps
self.engine_Isps = engine_Isps
self.sigmas = sigmas
self.PL = PL
self.Mission = Mission
print(self.name + ' has been initialized')
if self.Mission.input[0] == 'One':
self.m_PAF = 7 # CAD estimate of PAF mass
elif self.Mission.input[0] == 'Two':
self.m_PAF = 14 # CAD estimate of PAF mass
self.m_engine_0 = 22 # Edberg's textbook
# LR101 Engine Info (22kg weight) http://astronautix.com/l/lr101-11.html
def initMassEstimates(self):
df_masses = pd.read_csv('LVMasses\\' + self.name + 'MassEstimate.csv', index_col=0)
# Initialize m_gross of the Launch Vehicle
self.m_gross = df_masses.iloc[6, 2]
# Initialize propellant masses (list of masses per step)
self.m_p = list(df_masses.iloc[3, :].astype(float)) # get list from panda series
self.m_p.reverse() # reverse list order (from steps bottom to top)
self.m_p = [item for item in self.m_p if item != 0] # remove 0 values
# Initialize structural masses (list of masses per step)
self.m_s = list(df_masses.iloc[4, :].astype(float)) # get list from panda series
self.m_s.reverse() # reverse list order (from steps bottom to top)
self.m_s = [item for item in self.m_s if item != 0] # remove 0 values
# Initialize stage masses (list of masses per step)
self.m_0 = list(df_masses.iloc[5, :].astype(float)) # get list from panda series
self.m_0.reverse() # reverse list order (from steps bottom to top)
self.m_0 = [item for item in self.m_0 if item != 0] # remove 0 values
print(self.m_0)
print(self.m_s)
print(self.m_p)
self.mp_actual = [] # initialized in initMasses
self.mi_actual = [] # initialized in rearrangeDF
self.mf_actual = [] # initialized in rearrangeDF
print("the gross mass is " + str (self.m_gross))
print("the stage masses are " + str(self.m_0))
print("the propellant masses are " + str(self.m_p))
print("the structural masses are " + str(self.m_s))
def initSteps(self, listOfSteps):
print("Initializing and sizing steps...")
self.listOfSteps = listOfSteps
self.r = []
for i in range(len(self.listOfSteps)):
step = listOfSteps[i]
self.r.append(step.r)
def initInterstages(self): # adds interstage to Step object as its "Forward Skirt"
pi = 3.1415926535897932#3846264338327950288
#self.listOfInterstages = []
for i in range(len(self.listOfSteps)):
step = self.listOfSteps[i]
temp_interstage = []
if i == len(self.listOfSteps)-1: # if last step: last step doesn't have interstage
temp_interstage.append(0)
temp_interstage.append(0)
else: # if not last step
if step.propulsion == 'Liquid':
temp_interstage.append(step.dome_f[0] + self.listOfSteps[i+1].L_n + step.r/4) # interstage length: gap of r/4 between the current step's tank dome and upper step's nozzle exit
temp_interstage.append(pi*(step.r + self.listOfSteps[i+1].r)* pow( pow(step.r - self.listOfSteps[i+1].r, 2) + pow(temp_interstage[0], 2), 1/2) ) # interstage surface area -> thin frustum of cone
elif step.propulsion == 'Solid':
if step.parallel:
temp_interstage.append(2 * step.press_tank[0] + step.r/2) # "interstage" length is actually the fwd skirt of the booster: total height of pressure tank + gap of r/2
temp_interstage.append(2 * pi * step.r * temp_interstage[0]) # interstage surface area -> thin cylinder
else:
temp_interstage.append(2 * step.press_tank[0] + self.listOfSteps[i+1].L_n + step.r/4) # interstage length: current step's total pressure tank length + gap of r/4 + next step's nozzle length
temp_interstage.append(pi*(step.r + self.listOfSteps[i+1].r)* pow( pow(step.r - self.listOfSteps[i+1].r, 2) + pow(temp_interstage[0], 2), 1/2) ) # interstage surface area -> thin frustum of cone
step.interstage = temp_interstage # set temp_interstage as the step's 'interstage' attribute
#self.listOfSteps[0].eng_protrude_dist = self.listOfSteps[0].L_n/2
def massMoments(self, load_type):
print("Generating Mass Moments Table...")
payload_items = ['TopOfPLF', 'PLF', 'Payload', 'PAF']
step_items_liquid = ['Forward Skirt', 'Avionics', 'Wiring', 'Fuel Dome Top', 'Fuel Cylinder', 'Fuel Dome Bottom', 'Fuel Insulation', 'Fuel Residual',
'Intertank', 'Ox Dome Top', 'Ox Cylinder', 'Ox Dome Bottom', 'Ox Insulation', 'Ox Residual', 'Pressurant Tank', 'Aft Skirt', 'Thrust Structure',
'Gimballs', 'Engines', 'Fuel', 'Oxidizer']
step_items_solid =['Nose Cone', 'Forward Skirt', 'Avionics', 'Wiring', 'Pressurant Tank', 'SRM Dome Top', 'Solid Propellant Casing', 'SRM Dome Bottom', 'Solid Propellant Residual', 'Aft Skirt',
'Gimballs', 'Nozzle', 'Solid Propellant']
#num_items = len(payload_items) + self.num_steps * len(step_items)
df_temp = pd.DataFrame(columns=['Item', 'Height (m)', 'Mass (kg)', 'Distance (m)', 'Moment (kg*m)', 'Thickness (m)', 'Distance from CM (m)', 'J0 (kg m^2)', 'm*CM^2 (kg m^2)', 'Jpitch/yaw', 'Jroll'],
index=range(len(payload_items)))
#df = pd.DataFrame(columns=['Item', 'Height (m)', 'Mass (kg)', 'Distance (m)', 'Moment (kg*m)', 'Thickness (m)', 'Distance from CM (m)', 'J0 (kg m^2)', 'm*CM^2 (kg m^2)', 'Jpitch/yaw', 'Jroll'],
# index=range(num_items))
self.df = self.appendItems(df_temp, payload_items, step_items_liquid, step_items_solid)
self.initHeights(self.df, payload_items, step_items_liquid, step_items_solid)
self.initThicknesses(self.df, payload_items, step_items_liquid, step_items_solid)
self.initMasses(self.df, payload_items, step_items_liquid, step_items_solid, load_type)
self.initDistances(self.df, payload_items, step_items_liquid, step_items_solid, load_type)
self.initMoments(self.df, payload_items, step_items_liquid, step_items_solid)
self.initJ0s(self.df, payload_items, step_items_liquid, step_items_solid)
#print("The sum of Moments is " + str(self.df['Moment (kg*m)'].sum()))
#print("The sum of Masses is " + str(self.df['Mass (kg)'].sum()))
self.CM_full = self.df['Moment (kg*m)'].sum()/self.df['Mass (kg)'].sum()
print("The CM fully loaded of " + self.name + " is " + str(self.CM_full))
self.initDistFromCM(self.df, payload_items, step_items_liquid, step_items_solid)
self.initmCMs(self.df, payload_items, step_items_liquid, step_items_solid)
self.initJPitchYaw(self.df, payload_items, step_items_liquid, step_items_solid)
self.initJRoll(self.df, payload_items, step_items_liquid, step_items_solid)
self.rearrangeDF(payload_items, step_items_liquid, step_items_solid) # must be called after initMassesLV and initMasses
if load_type == 'Ground Wind-Loads Condition':
self.df.to_csv('LVMassMoments\\'+self.name + 'GroundLoadsMassMoments.csv')
elif load_type == 'Max-Q Condition':
self.df.to_csv('LVMassMoments\\'+self.name + 'WindLoadsMassMoments.csv')
for i in self.listOfSteps:
print("step " + str(i.step_num) + " has a radius of " + str(i.r) + " m.")
#print("thrust sea_level is " + str(i.T_SL) + " and step mass is " + str(sum(self.m_0)))
def appendItems(self, df, pl_items, l_items, s_items):# initialize 'Item' names
for i in range(len(pl_items)): # initialize payload item names
df['Item'][i] = pl_items[i]
for i in range(len(self.listOfSteps)): # initialize step item names
step = self.listOfSteps[i]
if step.propulsion == 'Liquid': # if liquid step
for j in range(len(l_items)):
new_row = {'Item': l_items[j] + ' ' + str(step.step_num)}
df = df.append(new_row, ignore_index=True)
elif step.propulsion == 'Solid': # if solid step
for j in range(len(s_items)):
new_row = {'Item': s_items[j] + ' ' + str(step.step_num)}
df = df.append(new_row, ignore_index=True)
return df
def initHeights(self, df, pl_items, l_items, s_items ):
#print(self.listOfSteps)
df['Height (m)'][pl_items.index("PLF")] = sum(self.listOfSteps[len(self.listOfSteps)-1].fairing[0])
df['Height (m)'][pl_items.index("Payload")] = sum(self.listOfSteps[len(self.listOfSteps)-1].fairing[0])
df['Height (m)'][pl_items.index("PAF")] = " "
row = len(pl_items)
for i in range(len(self.listOfSteps)):
step = self.listOfSteps[i]
if step.propulsion == 'Liquid':
if i < len(self.listOfSteps) - 1: # if not the last step
df['Height (m)'][row + l_items.index("Forward Skirt")] = step.interstage[0] # Interstage 1 (still called fwd skirt)
#print("The forward skirt length is " + str(step.interstage[0]))
elif i == len(self.listOfSteps) - 1: #else if last step
df['Height (m)'][row + l_items.index("Forward Skirt")] = step.fwd_skirt[0] # fwd skirt
#print("The forward skirt length is " + str(step.fwd_skirt[0]))
#print("The fuel cyl length is " + str(step.cyl_f[0]))
df['Height (m)'][row + l_items.index("Avionics")] = " "
df['Height (m)'][row + l_items.index("Wiring")] = step.total_length
df['Height (m)'][row + l_items.index("Fuel Dome Top")] = step.dome_f[0]
df['Height (m)'][row + l_items.index("Fuel Cylinder")] = step.cyl_f[0]
df['Height (m)'][row + l_items.index("Fuel Dome Bottom")] = step.dome_f[0]
df['Height (m)'][row + l_items.index("Fuel Insulation")] = step.cyl_f[0] + 2 * step.dome_f[0]
df['Height (m)'][row + l_items.index("Fuel Residual")] = " "
df['Height (m)'][row + l_items.index("Intertank")] = step.intertank[0]
df['Height (m)'][row + l_items.index("Ox Dome Top")] = step.dome_ox[0]
df['Height (m)'][row + l_items.index("Ox Cylinder")] = step.cyl_ox[0]
df['Height (m)'][row + l_items.index("Ox Dome Bottom")] = step.dome_ox[0]
df['Height (m)'][row + l_items.index("Ox Insulation")] = step.cyl_ox[0] + 2 * step.dome_ox[0]
df['Height (m)'][row + l_items.index("Ox Residual")] = " "
df['Height (m)'][row + l_items.index("Pressurant Tank")] = 2 * step.press_tank[0]
df['Height (m)'][row + l_items.index("Aft Skirt")] = step.aft_skirt[0]
df['Height (m)'][row + l_items.index("Thrust Structure")] = step.T_struct
df['Height (m)'][row + l_items.index("Gimballs")] = " "
df['Height (m)'][row + l_items.index("Engines")] = step.L_n
df['Height (m)'][row + l_items.index("Fuel")] = step.cyl_f[0] + 2 * step.dome_f[0]
df['Height (m)'][row + l_items.index("Oxidizer")] = step.cyl_ox[0] + 2 * step.dome_ox[0]
row += len(l_items)
elif step.propulsion == 'Solid':
if i < len(self.listOfSteps) - 1: # if not the last step
if step.parallel:
df['Height (m)'][row + s_items.index("Nose Cone")] = step.fairing[0]
df['Height (m)'][row + s_items.index("Forward Skirt")] = step.interstage[0]
elif i == len(self.listOfSteps) - 1: #else if last step
df['Height (m)'][row + s_items.index("Forward Skirt")] = step.fwd_skirt[0]
df['Height (m)'][row + s_items.index("Avionics")] = " "
df['Height (m)'][row + s_items.index("Wiring")] = step.total_length
df['Height (m)'][row + s_items.index("Pressurant Tank")] = 2 * step.press_tank[0]
#print(step.dome_f[0])
df['Height (m)'][row + s_items.index("SRM Dome Top")] = step.dome_f[0]
df['Height (m)'][row + s_items.index("Solid Propellant Casing")] = step.srm_casing[0]
df['Height (m)'][row + s_items.index("SRM Dome Bottom")] = step.dome_f[0]
df['Height (m)'][row + s_items.index("Solid Propellant Residual")] = " "
df['Height (m)'][row + s_items.index("Aft Skirt")] = step.aft_skirt[0]
df['Height (m)'][row + s_items.index("Gimballs")] = " "
df['Height (m)'][row + s_items.index("Nozzle")] = step.L_n
df['Height (m)'][row + s_items.index("Solid Propellant")] = step.srm_casing[0]
row += len(s_items)
def initThicknesses(self, df, pl_items, l_items, s_items):
df['Thickness (m)'][pl_items.index("PLF")] = 1
df['Thickness (m)'][pl_items.index("Payload")] = 0
df['Thickness (m)'][pl_items.index("PAF")] = 0
row = len(pl_items)
for i in range(len(self.listOfSteps)):
step = self.listOfSteps[i]
if step.propulsion == 'Liquid':
if i < len(self.listOfSteps) - 1:
df['Thickness (m)'][row + l_items.index("Forward Skirt")] = 1
elif i == len(self.listOfSteps) - 1:
df['Thickness (m)'][row + l_items.index("Forward Skirt")] = 1
df['Thickness (m)'][row + l_items.index("Avionics")] = 0
df['Thickness (m)'][row + l_items.index("Wiring")] = 0
df['Thickness (m)'][row + l_items.index("Pressurant Tank")] = 1
df['Thickness (m)'][row + l_items.index("Fuel Dome Top")] = 1
df['Thickness (m)'][row + l_items.index("Fuel Cylinder")] = 1
df['Thickness (m)'][row + l_items.index("Fuel Dome Bottom")] = 1
df['Thickness (m)'][row + l_items.index("Fuel Insulation")] = 0
df['Thickness (m)'][row + l_items.index("Fuel Residual")] = 0
df['Thickness (m)'][row + l_items.index("Intertank")] = 1
df['Thickness (m)'][row + l_items.index("Ox Dome Top")] = 1
df['Thickness (m)'][row + l_items.index("Ox Cylinder")] = 1
df['Thickness (m)'][row + l_items.index("Ox Dome Bottom")] = 1
df['Thickness (m)'][row + l_items.index("Ox Insulation")] = 0
df['Thickness (m)'][row + l_items.index("Ox Residual")] = 0
df['Thickness (m)'][row + l_items.index("Pressurant Tank")] = 1
df['Thickness (m)'][row + l_items.index("Aft Skirt")] = 1
df['Thickness (m)'][row + l_items.index("Thrust Structure")] = 0
df['Thickness (m)'][row + l_items.index("Gimballs")] = 0
df['Thickness (m)'][row + l_items.index("Engines")] = 0
df['Thickness (m)'][row + l_items.index("Fuel")] = 0
df['Thickness (m)'][row + l_items.index("Oxidizer")] = 0
if ((self.name == 'Minerva-1') | (self.name == 'Minerva-2')) & (step.step_num == 1): # POST BUCKLING ANALYSIS CHANGES
df['Thickness (m)'][row + l_items.index("Ox Cylinder")] = 1.5
df['Thickness (m)'][row + l_items.index("Fuel Cylinder")] = 1.5
df['Thickness (m)'][row + l_items.index("Aft Skirt")] = 1.9
elif ((self.name == 'Latona-1') & (step.step_num == 1)):
df['Thickness (m)'][row + l_items.index("Aft Skirt")] = 1.5
elif ((self.name == 'Latona-2') & (step.step_num == 2)):
df['Thickness (m)'][row + l_items.index("Aft Skirt")] = 1.5
elif ((self.name == 'Zephyr-1') | (self.name == 'Zephyr-2')) & (step.step_num == 1):
df['Thickness (m)'][row + l_items.index('Forward Skirt')] = 1.19
df['Thickness (m)'][row + l_items.index('Fuel Cylinder')] = 1.08
df['Thickness (m)'][row + l_items.index('Ox Cylinder')] = 1.42
df['Thickness (m)'][row + l_items.index('Intertank')] = 1.51
df['Thickness (m)'][row + l_items.index('Aft Skirt')] = 1.95
row += len(l_items)
elif step.propulsion == 'Solid':
if i < len(self.listOfSteps) - 1:
if step.parallel:
df['Thickness (m)'][row + s_items.index("Nose Cone")] = 1
df['Thickness (m)'][row + s_items.index("Forward Skirt")] = 1
elif i == len(self.listOfSteps) - 1:
df['Thickness (m)'][row + s_items.index("Forward Skirt")] = 1
df['Thickness (m)'][row + s_items.index("Avionics")] = 0
df['Thickness (m)'][row + s_items.index("Wiring")] = 0
df['Thickness (m)'][row + s_items.index("Pressurant Tank")] = 1
df['Thickness (m)'][row + s_items.index("SRM Dome Top")] = 1
df['Thickness (m)'][row + s_items.index("Solid Propellant Casing")] = 1
df['Thickness (m)'][row + s_items.index("SRM Dome Bottom")] = 1
df['Thickness (m)'][row + s_items.index("Solid Propellant Residual")] = 0
df['Thickness (m)'][row + s_items.index("Aft Skirt")] = 1
df['Thickness (m)'][row + s_items.index("Gimballs")] = 0
df['Thickness (m)'][row + s_items.index("Nozzle")] = 0
df['Thickness (m)'][row + s_items.index("Solid Propellant")] = 0
row += len(s_items)
# multiply thicknesses by 0.001 m/mm after initializing .
df['Thickness (m)'] = df['Thickness (m)']*0.001
def initMasses(self, df, pl_items, l_items, s_items, load_type): # Divided additional engine mass of 59 kg by 3, wiring and avionics by 10
# Load in max q data from matlab-generated .csv
if load_type == 'Max-Q Condition':
df_maxq = pd.read_csv('LVMasses\\Max Q Conditions_' + self.name + '.csv')
#print(df_maxq)
#print(df_maxq.iloc[0,3])
# mass burned is on row 1, column 4 of df
row = len(pl_items)
for i in range(len(self.listOfSteps)):
step = self.listOfSteps[i]
if step.propulsion == 'Liquid':
if i < len(self.listOfSteps) - 1: # if not last step
df['Mass (kg)'][row + l_items.index("Forward Skirt")] = step.interstage[1] * self.rho_body * df['Thickness (m)'][row + l_items.index("Forward Skirt")]
elif i == len(self.listOfSteps) - 1: # if last step
df['Mass (kg)'][row + l_items.index("Forward Skirt")] = step.fwd_skirt[1] * self.rho_body * df['Thickness (m)'][row + l_items.index("Forward Skirt")]
df['Mass (kg)'][row + l_items.index("Avionics")] = 0.84 # mass of new avionics technology taken from NASA (https://technology.nasa.gov/patent/TOP2-274)
df['Mass (kg)'][row + l_items.index("Wiring")] = 1.058*pow(self.m_0[i], 1/2) * pow(step.total_length, 1/4)/10
# Skin Mass Calculation
df['Mass (kg)'][row + l_items.index("Fuel Dome Top")] = step.dome_f[1] * step.rho_f_tank * df['Thickness (m)'][row + l_items.index("Fuel Dome Top")]
df['Mass (kg)'][row + l_items.index("Fuel Cylinder")] = step.cyl_f[1] * step.rho_f_tank * df['Thickness (m)'][row + l_items.index("Fuel Cylinder")]
df['Mass (kg)'][row + l_items.index("Fuel Dome Bottom")] = step.dome_f[1] * step.rho_f_tank * df['Thickness (m)'][row + l_items.index("Fuel Dome Top")]
# MER Mass Calculation
#tank_vol = 2 * step.dome_f[2] + step.cyl_f[2]
#if step.propellants == 'Kerolox':
# # relation for tank weight by mass (Table 8.6) for RP-1
# df['Mass (kg)'][row + l_items.index("Fuel Dome Top")] = step.dome_f[2] / tank_vol * 0.0148 * step.m_f_ideal
# df['Mass (kg)'][row + l_items.index("Fuel Cylinder")] = step.cyl_f[2] / tank_vol * 0.0148 * step.m_f_ideal
# df['Mass (kg)'][row + l_items.index("Fuel Dome Bottom")] = step.dome_f[2] / tank_vol * 0.0148 * step.m_f_ideal
#else:
# # relation for tank weight by volume (Table 8.7) for anything but LH2
# df['Mass (kg)'][row + l_items.index("Fuel Dome Top")] = step.dome_f[2] * 12.16
# df['Mass (kg)'][row + l_items.index("Fuel Cylinder")] = step.cyl_f[2] * 12.16
# df['Mass (kg)'][row + l_items.index("Fuel Dome Bottom")] = step.dome_f[2] * 12.16
df['Mass (kg)'][row + l_items.index("Ox Dome Top")] = step.dome_ox[1] * step.rho_ox_tank * df['Thickness (m)'][row + l_items.index("Ox Dome Top")]
df['Mass (kg)'][row + l_items.index("Ox Cylinder")] = step.cyl_ox[1] * step.rho_ox_tank * df['Thickness (m)'][row + l_items.index("Ox Cylinder")]
df['Mass (kg)'][row + l_items.index("Ox Dome Bottom")] = step.dome_ox[1] * step.rho_ox_tank * df['Thickness (m)'][row + l_items.index("Ox Dome Bottom")]
df['Mass (kg)'][row + l_items.index("Fuel Insulation")] = (step.cyl_f[1] + 2 * step.dome_f[1]) * step.SA_rho_insulation['Fuel']
df['Mass (kg)'][row + l_items.index("Fuel Residual")] = step.residual_prop_perc * step.m_f_ideal
df['Mass (kg)'][row + l_items.index("Intertank")] = step.intertank[1] * self.rho_body * df['Thickness (m)'][row + l_items.index("Intertank")]
#tank_vol = 2 * step.dome_ox[2] + step.cyl_ox[2]
# relation for tank weight by mass (Table 8.6) for LOX
#df['Mass (kg)'][row + l_items.index("Ox Dome Top")] = step.dome_ox[2] / tank_vol * 0.0107 * step.m_ox_ideal
#df['Mass (kg)'][row + l_items.index("Ox Cylinder")] = step.cyl_ox[2] / tank_vol * 0.0107 * step.m_ox_ideal
#df['Mass (kg)'][row + l_items.index("Ox Dome Bottom")] = step.dome_ox[2] / tank_vol * 0.0107 * step.m_ox_ideal
df['Mass (kg)'][row + l_items.index("Ox Insulation")] = (step.cyl_ox[1] + 2 * step.dome_ox[1]) * step.SA_rho_insulation['Oxidizer']
df['Mass (kg)'][row + l_items.index("Ox Residual")] = step.residual_prop_perc * step.m_ox_ideal
df['Mass (kg)'][row + l_items.index("Pressurant Tank")] = step.press_tank[1] * self.rho_body * df['Thickness (m)'][row + l_items.index("Pressurant Tank")]
#df['Mass (kg)'][row + l_items.index("Pressurant Tank")] = step.m_press * 2 # relation for tank weight by mass (Table 8.7)
df['Mass (kg)'][row + l_items.index("Aft Skirt")] = step.aft_skirt[1] * self.rho_body * df['Thickness (m)'][row + l_items.index("Aft Skirt")]
df['Mass (kg)'][row + l_items.index("Thrust Structure")] = 2.55*pow(10, -4)*step.T_SL
df['Mass (kg)'][row + l_items.index("Gimballs")] = step.num_gimballed_engines * 237.8*pow(step.T_SL_engine / step.p_c, 0.9375)
df['Mass (kg)'][row + l_items.index("Engines")] = step.num_engines * (step.T_SL_engine * (7.81 * pow(10, -4) + 3.37 * pow(10, -5) * sqrt(step.epsilon)) + self.m_engine_0)
df['Mass (kg)'][row + l_items.index("Fuel")] = step.m_f_ideal + step.fuel_frac * step.startup_prop
df['Mass (kg)'][row + l_items.index("Oxidizer")] = step.m_ox_ideal + step.ox_frac * step.startup_prop
self.mp_actual.append(df['Mass (kg)'][row + l_items.index("Fuel")] + df['Mass (kg)'][row + l_items.index("Oxidizer")])
if (load_type == "Max-Q Condition") & (step.step_num == 1):
df['Mass (kg)'][row + l_items.index("Fuel")] = df['Mass (kg)'][row + l_items.index("Fuel")] - df_maxq.iloc[0,4]*step.fuel_frac
df['Mass (kg)'][row + l_items.index("Oxidizer")] = df['Mass (kg)'][row + l_items.index("Oxidizer")] - df_maxq.iloc[0,4]*(1-step.fuel_frac)
row += len(l_items)
elif step.propulsion == 'Solid':
if i < len(self.listOfSteps) - 1: # if not last step
if step.parallel:
df['Mass (kg)'][row + s_items.index("Nose Cone")] = (step.fairing[1] * self.rho_body * df['Thickness (m)'][row + s_items.index("Nose Cone")])
df['Mass (kg)'][row + s_items.index("Gimballs")] = 0
else:
df['Mass (kg)'][row + s_items.index("Gimballs")] = step.num_gimballed_engines * 237.8*pow(step.T_SL_engine / step.p_c, 0.9375)
df['Mass (kg)'][row + s_items.index("Forward Skirt")] = step.interstage[1] * self.rho_body * df['Thickness (m)'][row + s_items.index("Forward Skirt")]
elif i == len(self.listOfSteps) - 1: # if last step
df['Mass (kg)'][row + s_items.index("Forward Skirt")] = step.fwd_skirt[1] * self.rho_body * df['Thickness (m)'][row + s_items.index("Forward Skirt")]
df['Mass (kg)'][row + s_items.index("Avionics")] = 0.84 # mass of new avionics technology taken from NASA (https://technology.nasa.gov/patent/TOP2-274)
df['Mass (kg)'][row + s_items.index("Wiring")] = 1.058*pow(self.m_0[i], 1/2) * pow(step.total_length, 1/4)/10
df['Mass (kg)'][row + s_items.index("Pressurant Tank")] = step.press_tank[1] * self.rho_body * df['Thickness (m)'][row + s_items.index("Pressurant Tank")]
#df['Mass (kg)'][row + s_items.index("Pressurant Tank")] = step.m_press * 2 # relation for tank weight (Table 8.7)
m_srm = step.k_SRM * step.m_prop_tot
SA_srm = 2*step.dome_f[1]+step.srm_casing[1]
#m_srm = SA_srm*self.rho_body*0.001
df['Mass (kg)'][row + s_items.index("SRM Dome Top")] = m_srm * step.dome_f[1] / SA_srm # mass by percent SA of SRM
df['Mass (kg)'][row + s_items.index("Solid Propellant Casing")] = m_srm * step.srm_casing[1] / SA_srm # mass by percent SA of SRM
df['Mass (kg)'][row + s_items.index("SRM Dome Bottom")] = m_srm * step.dome_f[1] / SA_srm # mass by percent SA of SRM
df['Mass (kg)'][row + s_items.index("Solid Propellant Residual")] = step.residual_prop
df['Mass (kg)'][row + s_items.index("Aft Skirt")] = step.aft_skirt[1] * self.rho_body * df['Thickness (m)'][row + s_items.index("Aft Skirt")]
df['Mass (kg)'][row + s_items.index("Nozzle")] = 0
df['Mass (kg)'][row + s_items.index("Solid Propellant")] = step.m_prop_tot
self.mp_actual.append(step.m_prop_tot*step.multiplier)
if (load_type == "Max-Q Condition"):
if (self.name == 'Latona-1'):
if step.step_num == 1:
df['Mass (kg)'][row + s_items.index("Solid Propellant")] = df['Mass (kg)'][row + s_items.index("Solid Propellant")] - df_maxq.iloc[0][4] # Latona 1 case
elif self.name == 'Latona-2':
if (step.step_num == 1) & step.parallel:
print(df_maxq.iloc[0,5])
df['Mass (kg)'][row + s_items.index("Solid Propellant")] = df_maxq.iloc[0,5] # propellant mass OF EACH booster
elif step.step_num == 2:
print(df_maxq.iloc[0,6])
df['Mass (kg)'][row + s_items.index("Solid Propellant")] = df_maxq.iloc[0,6] # propellant mass of main stage
row += len(s_items)
df['Mass (kg)'] = df['Mass (kg)']*step.multiplier # be careful here multiplying the mass column for each step iteration. This will result in
# multiplying all the previously instantiated step's masses in the dataframe by the current's step's multiplier.
# It's okay here since only the 1st step's multiplier != 1, but be aware.
# could fix by entering inside loop and doing if step.parallel -> if step.propulsion == liq or sol ->
# df['Mass (kg)'][index_start:index_end]=df['Mass (kg)'][index_start:index_end]*step.multiplier, where index_end is the current row + s/l_items.index and
# index_start = index_end - (num_l/s items)
df['Mass (kg)'][pl_items.index("PLF")] = sum(self.listOfSteps[len(self.listOfSteps)-1].fairing[1]) * self.listOfSteps[len(self.listOfSteps)-1].rho_fairing * df['Thickness (m)'][pl_items.index("PLF")]
#print("Payload Fairing Cylinder SA is " + str(self.listOfSteps[len(self.listOfSteps)-1].fairing[1][0]))
#print("Payload Fairing Cone SA is " + str(self.listOfSteps[len(self.listOfSteps)-1].fairing[1][1]))
#print("Total Payload Fairing SA is " + str(sum(self.listOfSteps[len(self.listOfSteps)-1].fairing[1])))
df['Mass (kg)'][pl_items.index("Payload")] = self.PL
df['Mass (kg)'][pl_items.index("PAF")] = self.m_PAF
def initDistances(self, df, pl_items, l_items, s_items, load_type): # initiate distances from bottom of aft skirt to CM of component
# Note the distances are initialized in reverse order, but maintain their order in the dataframe df
pi = 3.1415926535897932
row = len(pl_items)
CG = 0
for i in range(len(self.listOfSteps)):
step = self.listOfSteps[i]
if step.propulsion == "Liquid":
CG += step.r/4
df['Distance (m)'][row + l_items.index("Engines")] = CG
CG += step.L_n - step.r/4
df['Distance (m)'][row + l_items.index("Gimballs")] = CG
CG += step.T_struct/2 - step.L_n
df['Distance (m)'][row + l_items.index("Thrust Structure")] = CG
CG += step.aft_skirt[0]/2 - step.T_struct/2
df['Distance (m)'][row + l_items.index("Aft Skirt")] = CG
CG += step.aft_skirt[0]/2 - 4 * step.dome_ox[0]/(3 * pi) #+ step.dome_ox[0] # add to CG of ox dome bottom (gap of step.r/2)
print("CG of dome from bottom of dome = " + str(4 * step.dome_ox[0]/(3 * pi)))
df['Distance (m)'][row + l_items.index("Ox Dome Bottom")] = CG
CG += 4 * step.dome_ox[0]/(3 * pi) + step.cyl_ox[0]/2
df['Distance (m)'][row + l_items.index("Ox Cylinder")] = CG
df['Distance (m)'][row + l_items.index("Ox Insulation")] = CG
df['Distance (m)'][row + l_items.index("Ox Residual")] = CG - step.cyl_ox[0]/2 - step.dome_ox[0]/2 # residual CG sits in the middle of the bottom ox dome tank
df['Distance (m)'][row + l_items.index("Pressurant Tank")] = CG
# if load_type == "Ground Wind-Loads Condition":
# df['Distance (m)'][row + l_items.index("Oxidizer")] = CG
# elif load_type == "Max-Q Condition":
# # max q condition. delete for ground load condition
vol_ox = df['Mass (kg)'][row + l_items.index("Oxidizer")]/step.rho_ox
vol_ox_cyl_full = vol_ox - step.dome_ox[2]
m_dome_ox = step.dome_ox[2] * step.rho_ox
m_cyl_ox = vol_ox_cyl_full * step.rho_ox
cg_dome = step.dome_ox[0]- 4 * step.dome_ox[0]/(3 * pi) # from bottom of dome
cg_cyl = step.dome_ox[0] + (vol_ox_cyl_full/(pi * pow(step.r,2)))/2 # from bottom of dome
cg_ox = (m_dome_ox * cg_dome + m_cyl_ox * cg_cyl)/(m_dome_ox + m_cyl_ox) # resultant cg of oxidizer from bottom of dome
df['Distance (m)'][row + l_items.index("Oxidizer")] = CG - step.cyl_ox[0]/2 - step.dome_ox[0] + cg_ox # subtract cg back down to bottom of ox dome and add cg_ox from there
#df['Distance (m)'][row + l_items.index("Oxidizer")] = CG
CG += step.cyl_ox[0]/2 + 4 * step.dome_ox[0]/(3 * pi)
df['Distance (m)'][row + l_items.index("Ox Dome Top")] = CG
CG += - 4 * step.dome_ox[0]/(3 * pi) + step.intertank[0]/2
df['Distance (m)'][row + l_items.index("Intertank")] = CG
CG += step.r/4 + step.dome_f[0] - 4 * step.dome_f[0]/(3 * pi)
df['Distance (m)'][row + l_items.index("Fuel Dome Bottom")] = CG
CG += 4 * step.dome_f[0]/(3 * pi) + step.cyl_f[0]/2
df['Distance (m)'][row + l_items.index("Fuel Cylinder")] = CG
df['Distance (m)'][row + l_items.index("Fuel Insulation")] = CG
df['Distance (m)'][row + l_items.index("Fuel Residual")] = CG - step.cyl_f[0]/2 - step.dome_f[0]/2 # residual CG sits in the middle of the bottom fuel dome tank
# if load_type == "Ground Wind-Loads Condition":
# df['Distance (m)'][row + l_items.index("Fuel")] = CG
# elif load_type == "Max-Q Condition":
vol_f = df['Mass (kg)'][row + l_items.index("Fuel")]/step.rho_f
vol_f_cyl_full = vol_f - step.dome_f[2]
m_dome_f = step.dome_f[2] * step.rho_f
m_cyl_f = vol_f_cyl_full * step.rho_f
CG_dome = step.dome_f[0]- 4 * step.dome_f[0]/(3 * pi) # from bottom of dome
CG_cyl = step.dome_f[0] + (vol_f_cyl_full/(pi * pow(step.r,2)))/2 # from bottom of dome
CG_f = (m_dome_f * CG_dome + m_cyl_f * CG_cyl)/(m_dome_f + m_cyl_f) # Resultant CG of fuel from bottom of dome
df['Distance (m)'][row + l_items.index("Fuel")] = CG - step.cyl_f[0]/2 - step.dome_f[0] + CG_f # subtract CG back down to bottom of fuel dome and add CG_f from there
CG += step.cyl_f[0]/2 + 4 * step.dome_f[0]/(3 * pi)
df['Distance (m)'][row + l_items.index("Fuel Dome Top")] = CG
df['Distance (m)'][row + l_items.index("Wiring")] = 0
if i < len(self.listOfSteps) - 1: # if not last step NOTE: invert step.interstage CG calc by getting rid of step.interstage[0] and changing the '-' (CG calc) to a '+' CG += - 4 * step.dome_f[0]/(3 * pi) + step.interstage[0] - step.interstage[0]/3*(2*self.listOfSteps[i+1].r + step.r)/(self.listOfSteps[i+1].r + step.r) #formual for centroid of trapezoid)
CG += -4 * step.dome_f[0]/(3 * pi) + step.interstage[0]/3*(2*self.listOfSteps[i+1].r + step.r)/(self.listOfSteps[i+1].r + step.r)
df['Distance (m)'][row + l_items.index("Forward Skirt")] = CG
df['Distance (m)'][row + l_items.index("Avionics")] = CG
CG += step.interstage[0] - step.interstage[0]/3*(2*self.listOfSteps[i+1].r + step.r)/(self.listOfSteps[i+1].r + step.r)
elif i == len(self.listOfSteps) - 1: # if last step
CG += step.fwd_skirt[0]/2 - 4 * step.dome_f[0]/(3 * pi)
df['Distance (m)'][row + l_items.index("Forward Skirt")] = CG
df['Distance (m)'][row + l_items.index("Avionics")] = CG
CG += step.fwd_skirt[0]/2
if self.Mission.input[0] == 'One':
df['Distance (m)'][pl_items.index("PAF")] = CG # Mission 1: place distance of PAF at bottom of PLF cylinder
elif self.Mission.input[0] == 'Two':
df['Distance (m)'][pl_items.index("PAF")] = CG + step.fairing[0][0]/2 # Mission 2: place distance of PAF in the middle of PLF cylinder
CG += step.fairing[0][0]/2
df['Distance (m)'][pl_items.index("Payload")] = CG # middle of fairing_cylinder
CG -= step.fairing[0][0]/2 # Subtract CG to get back down to PAF
# CG of payload fairing = (m_cyl*CG_cyl + m_cone*CG_cone)/m_total
CG += (step.fairing[1][0]*step.rho_fairing*df['Thickness (m)'][pl_items.index("PLF")]*step.fairing[0][0]/2 + step.fairing[1][1]*step.rho_fairing*df['Thickness (m)'][pl_items.index("PLF")]*(step.fairing[0][1]/3 + step.fairing[0][0])) / (df['Mass (kg)'][pl_items.index("PLF")]) # CG of payload fairing = (m_cyl*CG_cyl + m_cone*CG_cone)/m_total (CG from PAF)
df['Distance (m)'][pl_items.index("PLF")] = CG
# Subtract CG to get back down to PAF
CG -= (step.fairing[1][0]*step.rho_fairing*df['Thickness (m)'][pl_items.index("PLF")]*step.fairing[0][0]/2 + step.fairing[1][1]*step.rho_fairing*df['Thickness (m)'][pl_items.index("PLF")]*(step.fairing[0][1]/3 + step.fairing[0][0])) / (df['Mass (kg)'][pl_items.index("PLF")]) # CG of payload fairing = (m_cyl*CG_cyl + m_cone*CG_cone)/m_total (CG from PAF)
CG += sum(step.fairing[0]) # add total fairing height on top of PAF to get top of PLF
df['Distance (m)'][0] = CG # Top of PLF
row += len(l_items)
elif step.propulsion == 'Solid':
CG += step.r/4
df['Distance (m)'][row + s_items.index("Nozzle")] = CG
CG += step.L_n - step.r/4
df['Distance (m)'][row + s_items.index("Gimballs")] = CG
CG += step.aft_skirt[0]/2 - step.L_n
df['Distance (m)'][row + s_items.index("Aft Skirt")] = CG
CG += step.aft_skirt[0]/2 + 4 * step.dome_f[0]/(3 * pi)
df['Distance (m)'][row + s_items.index("SRM Dome Bottom")] = CG
CG += -4 * step.dome_f[0]/(3 * pi) + step.srm_casing[0]/2
df['Distance (m)'][row + s_items.index("Solid Propellant Casing")] = CG
df['Distance (m)'][row + s_items.index("Solid Propellant Residual")] = CG
if load_type == "Ground Wind-Loads Condition":
df['Distance (m)'][row + s_items.index("Solid Propellant")] = CG
elif load_type == "Max-Q Condition":
df['Distance (m)'][row + s_items.index("Solid Propellant")] = CG # Same CG since the solid propellant burns out radially
CG += step.srm_casing[0]/2 + 4 * step.dome_f[0]/(3 * pi)
df['Distance (m)'][row + s_items.index("SRM Dome Top")] = CG
df['Distance (m)'][row + s_items.index("Wiring")] = 0
if i < len(self.listOfSteps) - 1: # if not last step
if step.parallel: # interstage is cylindrical;
#start from bottom of SRM Dome Top
CG += -4 * step.dome_f[0]/(3 * pi) + step.interstage[0]/2
df['Distance (m)'][row + s_items.index("Forward Skirt")] = CG
df['Distance (m)'][row + s_items.index("Avionics")] = CG
CG += -step.interstage[0]/2 + step.r/2 + step.press_tank[0] # add gap of r/2 between solid propellant casing and pressurant tank
df['Distance (m)'][row + s_items.index("Pressurant Tank")] = CG
CG += -step.r/2 - step.press_tank[0] + step.interstage[0] + step.fairing[0]/3
df['Distance (m)'][row + s_items.index("Nose Cone")] = CG
else: # interstage is a cut-off-cone
#start from SRM Dome Top CG
CG += -4 * step.dome_f[0]/(3 * pi) + step.interstage[0]/3*(2*self.listOfSteps[i+1].r + step.r)/(self.listOfSteps[i+1].r + step.r) # ( using formula for centroid of trapezoid)
df['Distance (m)'][row + s_items.index("Forward Skirt")] = CG
fwd_skirt_CG = CG
df['Distance (m)'][row + s_items.index("Avionics")] = CG
CG += -step.interstage[0]/3*(2*self.listOfSteps[i+1].r + step.r)/(self.listOfSteps[i+1].r + step.r) + step.r/2 + step.press_tank[0] # add gap of r/2 between solid propellant casing and pressurant tank
df['Distance (m)'][row + s_items.index("Pressurant Tank")] = CG
CG = fwd_skirt_CG + step.interstage[0] - step.interstage[0]/3*(2*self.listOfSteps[i+1].r + step.r)/(self.listOfSteps[i+1].r + step.r)
elif i == len(self.listOfSteps) - 1: # if last step
CG += -4 * step.dome_f[0]/(3 * pi) # set CG to bottom of SRM Dome Top
df['Distance (m)'][row + s_items.index("Pressurant Tank")] = CG + 4 * step.dome_f[0]/(3 * pi) + step.press_tank[0] + step.r/2 # gap of step.r/2 from top of SRM Dome Top to bottom of pressure tank
CG += step.fwd_skirt[0]/2 # add to CG of fwd skirt starting from bottom of SRM Dome Top
df['Distance (m)'][row + s_items.index("Forward Skirt")] = CG
df['Distance (m)'][row + s_items.index("Avionics")] = CG
CG += step.fwd_skirt[0]/2
df['Distance (m)'][pl_items.index("PAF")] = CG
CG += step.fairing[0][0]/2
df['Distance (m)'][pl_items.index("Payload")] = CG
CG -= step.fairing[0][0]/2
#step.fairing[1][0]*self.rho_fairing
df['Distance (m)'][pl_items.index("PLF")] = CG
row += len(s_items)
if step.parallel: # be careful here, only properly sets CG if parallel is the 1st stage, not parallel subsequent stages (although it would never occur otherwise, be aware)
CG = 0
def initMoments(self, df, pl_items, l_items, s_items): # initiate distances from bottom of aft skirt to CM of component
# Note the distances are initialized in reverse order, but maintain their order in the dataframe df
#pi = 3.1415926535897932
row = len(pl_items)
CG = 0
for i in range(len(self.listOfSteps)):
step = self.listOfSteps[i]
if step.propulsion == "Liquid":
df['Moment (kg*m)'][row + l_items.index("Avionics")] = df['Distance (m)'][row + l_items.index("Avionics")] * df['Mass (kg)'][row + l_items.index("Avionics")]
df['Moment (kg*m)'][row + l_items.index("Wiring")] = 0
df['Moment (kg*m)'][row + l_items.index("Fuel Dome Top")] = df['Distance (m)'][row + l_items.index("Fuel Dome Top")] * df['Mass (kg)'][row + l_items.index("Fuel Dome Top")]
df['Moment (kg*m)'][row + l_items.index("Fuel Cylinder")] = df['Distance (m)'][row + l_items.index("Fuel Cylinder")] * df['Mass (kg)'][row + l_items.index("Fuel Cylinder")]
df['Moment (kg*m)'][row + l_items.index("Fuel Dome Bottom")] = df['Distance (m)'][row + l_items.index("Fuel Dome Bottom")] * df['Mass (kg)'][row + l_items.index("Fuel Dome Bottom")]
df['Moment (kg*m)'][row + l_items.index("Fuel Insulation")] = df['Distance (m)'][row + l_items.index("Fuel Insulation")] * df['Mass (kg)'][row + l_items.index("Fuel Insulation")]
df['Moment (kg*m)'][row + l_items.index("Fuel Residual")] = df['Distance (m)'][row + l_items.index("Fuel Residual")] * df['Mass (kg)'][row + l_items.index("Fuel Residual")]
df['Moment (kg*m)'][row + l_items.index("Intertank")] = df['Distance (m)'][row + l_items.index("Intertank")] * df['Mass (kg)'][row + l_items.index("Intertank")]
df['Moment (kg*m)'][row + l_items.index("Ox Dome Top")] = df['Distance (m)'][row + l_items.index("Ox Dome Top")] * df['Mass (kg)'][row + l_items.index("Ox Dome Top")]
df['Moment (kg*m)'][row + l_items.index("Ox Cylinder")] = df['Distance (m)'][row + l_items.index("Ox Cylinder")] * df['Mass (kg)'][row + l_items.index("Ox Cylinder")]
df['Moment (kg*m)'][row + l_items.index("Ox Dome Bottom")] = df['Distance (m)'][row + l_items.index("Ox Dome Bottom")] * df['Mass (kg)'][row + l_items.index("Ox Dome Bottom")]
df['Moment (kg*m)'][row + l_items.index("Ox Insulation")] = df['Distance (m)'][row + l_items.index("Ox Insulation")] * df['Mass (kg)'][row + l_items.index("Ox Insulation")]
df['Moment (kg*m)'][row + l_items.index("Ox Residual")] = df['Distance (m)'][row + l_items.index("Ox Residual")] * df['Mass (kg)'][row + l_items.index("Ox Residual")]
df['Moment (kg*m)'][row + l_items.index("Pressurant Tank")] = df['Distance (m)'][row + l_items.index("Pressurant Tank")] * df['Mass (kg)'][row + l_items.index("Pressurant Tank")]
df['Moment (kg*m)'][row + l_items.index("Aft Skirt")] = df['Distance (m)'][row + l_items.index("Aft Skirt")] * df['Mass (kg)'][row + l_items.index("Aft Skirt")]
df['Moment (kg*m)'][row + l_items.index("Thrust Structure")] = df['Distance (m)'][row + l_items.index("Thrust Structure")] * df['Mass (kg)'][row + l_items.index("Thrust Structure")]
df['Moment (kg*m)'][row + l_items.index("Gimballs")] = df['Distance (m)'][row + l_items.index("Gimballs")] * df['Mass (kg)'][row + l_items.index("Gimballs")]
df['Moment (kg*m)'][row + l_items.index("Engines")] = df['Distance (m)'][row + l_items.index("Engines")] * df['Mass (kg)'][row + l_items.index("Engines")]
df['Moment (kg*m)'][row + l_items.index("Fuel")] = df['Distance (m)'][row + l_items.index("Fuel")] * df['Mass (kg)'][row + l_items.index("Fuel")]
df['Moment (kg*m)'][row + l_items.index("Oxidizer")] = df['Distance (m)'][row + l_items.index("Oxidizer")] * df['Mass (kg)'][row + l_items.index("Oxidizer")]
if i < len(self.listOfSteps) - 1: # if not last step
CG += step.interstage[0]/3*(2*self.listOfSteps[i+1].r + step.r)/(self.listOfSteps[i+1].r + step.r) - 4 * step.dome_f[0]/(3 * pi) #( using formual for centroid of trapezoid)
df['Moment (kg*m)'][row + l_items.index("Forward Skirt")] = df['Distance (m)'][row + l_items.index("Forward Skirt")] * df['Mass (kg)'][row + l_items.index("Forward Skirt")]
CG += step.interstage[0] - step.interstage[0]/3*(2*self.listOfSteps[i+1].r + step.r)/(self.listOfSteps[i+1].r + step.r)
elif i == len(self.listOfSteps) - 1: # if last step
CG += step.fwd_skirt[0]/2 - 4 * step.dome_f[0]/(3 * pi) # fwd skirt
df['Moment (kg*m)'][row + l_items.index("Forward Skirt")] = df['Distance (m)'][row + l_items.index("Forward Skirt")] * df['Mass (kg)'][row + l_items.index("Forward Skirt")] # Interstage/Forward Skirt
df['Moment (kg*m)'][pl_items.index("PAF")] = df['Distance (m)'][pl_items.index("PAF")] * df['Mass (kg)'][pl_items.index("PAF")]
df['Moment (kg*m)'][pl_items.index("Payload")] = df['Distance (m)'][pl_items.index("Payload")] * df['Mass (kg)'][pl_items.index("Payload")]
df['Moment (kg*m)'][pl_items.index("PLF")] = df['Distance (m)'][pl_items.index("PLF")] * df['Mass (kg)'][pl_items.index("PLF")]
row += len(l_items)
elif step.propulsion == 'Solid':
if i < len(self.listOfSteps) - 1: # if not last step
if step.parallel:
df['Moment (kg*m)'][row + s_items.index("Nose Cone")] = df['Distance (m)'][row + s_items.index("Nose Cone")] * df['Mass (kg)'][row + s_items.index("Nose Cone")]
df['Moment (kg*m)'][row + s_items.index("Forward Skirt")] = df['Distance (m)'][row + s_items.index("Forward Skirt")] * df['Mass (kg)'][row + s_items.index("Forward Skirt")]
elif i == len(self.listOfSteps) - 1: # if last step
df['Moment (kg*m)'][row + s_items.index("Forward Skirt")] = df['Distance (m)'][row + s_items.index("Forward Skirt")] * df['Mass (kg)'][row + s_items.index("Forward Skirt")]
df['Moment (kg*m)'][pl_items.index("PAF")] = df['Distance (m)'][pl_items.index("PAF")] * df['Mass (kg)'][pl_items.index("PAF")]
df['Moment (kg*m)'][pl_items.index("Payload")] = df['Distance (m)'][pl_items.index("Payload")] * df['Mass (kg)'][pl_items.index("Payload")]
df['Moment (kg*m)'][pl_items.index("PLF")] = df['Distance (m)'][pl_items.index("PLF")] * df['Mass (kg)'][pl_items.index("PLF")]
df['Moment (kg*m)'][row + s_items.index("Avionics")] = df['Distance (m)'][row + s_items.index("Avionics")] * df['Mass (kg)'][row + s_items.index("Avionics")]
df['Moment (kg*m)'][row + s_items.index("Wiring")] = 0
df['Moment (kg*m)'][row + s_items.index("Pressurant Tank")] = df['Distance (m)'][row + s_items.index("Pressurant Tank")] * df['Mass (kg)'][row + s_items.index("Pressurant Tank")]
df['Moment (kg*m)'][row + s_items.index("SRM Dome Top")] = df['Distance (m)'][row + s_items.index("SRM Dome Top")] * df['Mass (kg)'][row + s_items.index("SRM Dome Top")]
df['Moment (kg*m)'][row + s_items.index("Solid Propellant Casing")] = df['Distance (m)'][row + s_items.index("Solid Propellant Casing")] * df['Mass (kg)'][row + s_items.index("Solid Propellant Casing")]
df['Moment (kg*m)'][row + s_items.index("SRM Dome Bottom")] = df['Distance (m)'][row + s_items.index("SRM Dome Bottom")] * df['Mass (kg)'][row + s_items.index("SRM Dome Bottom")]
df['Moment (kg*m)'][row + s_items.index("Solid Propellant Residual")] = df['Distance (m)'][row + s_items.index("Solid Propellant Residual")] * df['Mass (kg)'][row + s_items.index("Solid Propellant Residual")]
df['Moment (kg*m)'][row + s_items.index("Aft Skirt")] = df['Distance (m)'][row + s_items.index("Aft Skirt")] * df['Mass (kg)'][row + s_items.index("Aft Skirt")]
df['Moment (kg*m)'][row + s_items.index("Gimballs")] = df['Distance (m)'][row + s_items.index("Gimballs")] * df['Mass (kg)'][row + s_items.index("Gimballs")]
df['Moment (kg*m)'][row + s_items.index("Nozzle")] = df['Distance (m)'][row + s_items.index("Nozzle")] * df['Mass (kg)'][row + s_items.index("Nozzle")]
df['Moment (kg*m)'][row + s_items.index("Solid Propellant")] = df['Distance (m)'][row + s_items.index("Solid Propellant")] * df['Mass (kg)'][row + s_items.index("Solid Propellant")]
row += len(s_items)
def initDistFromCM(self, df, pl_items, l_items, s_items): # initiate distances from bottom of aft skirt to CM of component
# Note the distances are initialized in reverse order, but maintain their order in the dataframe df
#pi = 3.1415926535897932
row = len(pl_items)
for i in range(len(self.listOfSteps)):
step = self.listOfSteps[i]
if step.propulsion == "Liquid":
df['Distance from CM (m)'][row + l_items.index("Avionics")] = df['Distance (m)'][row + l_items.index("Avionics")] - self.CM_full
df['Distance from CM (m)'][row + l_items.index("Wiring")] = 0
df['Distance from CM (m)'][row + l_items.index("Fuel Dome Top")] = df['Distance (m)'][row + l_items.index("Fuel Dome Top")] - self.CM_full
df['Distance from CM (m)'][row + l_items.index("Fuel Cylinder")] = df['Distance (m)'][row + l_items.index("Fuel Cylinder")] - self.CM_full
df['Distance from CM (m)'][row + l_items.index("Fuel Dome Bottom")] = df['Distance (m)'][row + l_items.index("Fuel Dome Bottom")] - self.CM_full
df['Distance from CM (m)'][row + l_items.index("Fuel Insulation")] = df['Distance (m)'][row + l_items.index("Fuel Insulation")] - self.CM_full
df['Distance from CM (m)'][row + l_items.index("Fuel Residual")] = df['Distance (m)'][row + l_items.index("Fuel Residual")] - self.CM_full
df['Distance from CM (m)'][row + l_items.index("Intertank")] = df['Distance (m)'][row + l_items.index("Intertank")] - self.CM_full
df['Distance from CM (m)'][row + l_items.index("Ox Dome Top")] = df['Distance (m)'][row + l_items.index("Ox Dome Top")] - self.CM_full
df['Distance from CM (m)'][row + l_items.index("Ox Cylinder")] = df['Distance (m)'][row + l_items.index("Ox Cylinder")] - self.CM_full
df['Distance from CM (m)'][row + l_items.index("Ox Dome Bottom")] = df['Distance (m)'][row + l_items.index("Ox Dome Bottom")] - self.CM_full
df['Distance from CM (m)'][row + l_items.index("Ox Insulation")] = df['Distance (m)'][row + l_items.index("Ox Insulation")] - self.CM_full
df['Distance from CM (m)'][row + l_items.index("Ox Residual")] = df['Distance (m)'][row + l_items.index("Ox Residual")] - self.CM_full
df['Distance from CM (m)'][row + l_items.index("Pressurant Tank")] = df['Distance (m)'][row + l_items.index("Pressurant Tank")] - self.CM_full
df['Distance from CM (m)'][row + l_items.index("Aft Skirt")] = df['Distance (m)'][row + l_items.index("Aft Skirt")] - self.CM_full
df['Distance from CM (m)'][row + l_items.index("Thrust Structure")] = df['Distance (m)'][row + l_items.index("Thrust Structure")] - self.CM_full
df['Distance from CM (m)'][row + l_items.index("Gimballs")] = df['Distance (m)'][row + l_items.index("Gimballs")] - self.CM_full
df['Distance from CM (m)'][row + l_items.index("Engines")] = df['Distance (m)'][row + l_items.index("Engines")] - self.CM_full
df['Distance from CM (m)'][row + l_items.index("Fuel")] = df['Distance (m)'][row + l_items.index("Fuel")] - self.CM_full
df['Distance from CM (m)'][row + l_items.index("Oxidizer")] = df['Distance (m)'][row + l_items.index("Oxidizer")] - self.CM_full
if i < len(self.listOfSteps) - 1: # if not last step
# Interstage ( using formual for centroid of trapezoid)
df['Distance from CM (m)'][row + l_items.index("Forward Skirt")] = df['Distance (m)'][row + l_items.index("Forward Skirt")] - self.CM_full
elif i == len(self.listOfSteps) - 1: # if last step
df['Distance from CM (m)'][row + l_items.index("Forward Skirt")] = df['Distance (m)'][row + l_items.index("Forward Skirt")] - self.CM_full
df['Distance from CM (m)'][pl_items.index("PAF")] = df['Distance (m)'][pl_items.index("PAF")] - self.CM_full
df['Distance from CM (m)'][pl_items.index("Payload")] = df['Distance (m)'][pl_items.index("Payload")] - self.CM_full
df['Distance from CM (m)'][pl_items.index("PLF")] = df['Distance (m)'][pl_items.index("PLF")] - self.CM_full
row += len(l_items)
elif step.propulsion == 'Solid':
if i < len(self.listOfSteps) - 1: # if not last step
if step.parallel:
df['Distance from CM (m)'][row + s_items.index("Nose Cone")] = df['Distance (m)'][row + s_items.index("Nose Cone")] - self.CM_full
df['Distance from CM (m)'][row + s_items.index("Forward Skirt")] = df['Distance (m)'][row + s_items.index("Forward Skirt")] - self.CM_full
elif i == len(self.listOfSteps) - 1: # if last step
df['Distance from CM (m)'][row + s_items.index("Forward Skirt")] = df['Distance (m)'][row + s_items.index("Forward Skirt")] - self.CM_full
df['Distance from CM (m)'][pl_items.index("PAF")] = df['Distance (m)'][pl_items.index("PAF")] - self.CM_full
df['Distance from CM (m)'][pl_items.index("Payload")] = df['Distance (m)'][pl_items.index("Payload")] - self.CM_full
df['Distance from CM (m)'][pl_items.index("PLF")] = df['Distance (m)'][pl_items.index("PLF")] - self.CM_full
df['Distance from CM (m)'][row + s_items.index("Avionics")] = df['Distance (m)'][row + s_items.index("Avionics")] - self.CM_full
df['Distance from CM (m)'][row + s_items.index("Wiring")] = 0
df['Distance from CM (m)'][row + s_items.index("Pressurant Tank")] = df['Distance (m)'][row + s_items.index("Pressurant Tank")] - self.CM_full
df['Distance from CM (m)'][row + s_items.index("SRM Dome Top")] = df['Distance (m)'][row + s_items.index("SRM Dome Top")] - self.CM_full
df['Distance from CM (m)'][row + s_items.index("Solid Propellant Casing")] = df['Distance (m)'][row + s_items.index("Solid Propellant Casing")] - self.CM_full
df['Distance from CM (m)'][row + s_items.index("SRM Dome Bottom")] = df['Distance (m)'][row + s_items.index("SRM Dome Bottom")] - self.CM_full
df['Distance from CM (m)'][row + s_items.index("Solid Propellant Residual")] = 0
df['Distance from CM (m)'][row + s_items.index("Aft Skirt")] = df['Distance (m)'][row + s_items.index("Aft Skirt")] - self.CM_full
df['Distance from CM (m)'][row + s_items.index("Gimballs")] = df['Distance (m)'][row + s_items.index("Gimballs")] - self.CM_full
df['Distance from CM (m)'][row + s_items.index("Nozzle")] = df['Distance (m)'][row + s_items.index("Nozzle")] - self.CM_full
df['Distance from CM (m)'][row + s_items.index("Solid Propellant")] = df['Distance (m)'][row + s_items.index("Solid Propellant")] - self.CM_full
row += len(s_items)
# init J0's - double check some values such as payload, fairing, propellant tanks etc
def initJ0sOld(self, df, pl_items, l_items, s_items):
row = len(pl_items)
for i in range(len(self.listOfSteps)):
step = self.listOfSteps[i]
if step.propulsion == "Liquid":
df['J0 (kg m^2)'][row + l_items.index("Avionics")] = df['Mass (kg)'][row + l_items.index("Avionics")] * pow(step.r,2)/2
df['J0 (kg m^2)'][row + l_items.index("Wiring")] = df['Mass (kg)'][row + l_items.index("Wiring")] * pow(step.r,2)/2
df['J0 (kg m^2)'][row + l_items.index("Fuel Dome Top")] = df['Mass (kg)'][row + l_items.index("Fuel Dome Top")] * pow(step.r,2)
df['J0 (kg m^2)'][row + l_items.index("Fuel Cylinder")] = J0ThinCyl(df['Mass (kg)'][row + l_items.index("Fuel Cylinder")], step.r, step.cyl_f[0])
df['J0 (kg m^2)'][row + l_items.index("Fuel Dome Bottom")] = df['Mass (kg)'][row + l_items.index("Fuel Dome Bottom")] * pow(step.r,2)
df['J0 (kg m^2)'][row + l_items.index("Fuel Insulation")] = df['Mass (kg)'][row + l_items.index("Fuel Insulation")] * (pow(step.r,2)/2 + pow(df['Height (m)'][row + l_items.index("Fuel Insulation")],2)/12)
df['J0 (kg m^2)'][row + l_items.index("Fuel Residual")] = 0
df['J0 (kg m^2)'][row + l_items.index("Intertank")] = J0ThinCyl(df['Mass (kg)'][row + l_items.index("Intertank")], step.r, step.intertank[0])
df['J0 (kg m^2)'][row + l_items.index("Ox Dome Top")] = df['Mass (kg)'][row + l_items.index("Ox Dome Top")] * pow(step.r,2)
df['J0 (kg m^2)'][row + l_items.index("Ox Cylinder")] = J0ThinCyl(df['Mass (kg)'][row + l_items.index("Intertank")], step.r, step.intertank[0])
df['J0 (kg m^2)'][row + l_items.index("Ox Dome Bottom")] = df['Mass (kg)'][row + l_items.index("Ox Dome Bottom")] * pow(step.r,2)
df['J0 (kg m^2)'][row + l_items.index("Ox Insulation")] = df['Mass (kg)'][row + l_items.index("Ox Insulation")] * (pow(step.r,2)/2 + pow(df['Height (m)'][row + l_items.index("Ox Insulation")],2)/12)
df['J0 (kg m^2)'][row + l_items.index("Ox Residual")] = 0
df['J0 (kg m^2)'][row + l_items.index("Pressurant Tank")] = df['Mass (kg)'][row + l_items.index("Pressurant Tank")] * pow(step.r,2)
df['J0 (kg m^2)'][row + l_items.index("Aft Skirt")] = df['Mass (kg)'][row + l_items.index("Aft Skirt")] * ( pow(step.r,2) + pow(df['Height (m)'][row + l_items.index("Aft Skirt")],2)/12)
df['J0 (kg m^2)'][row + l_items.index("Thrust Structure")] = 0
df['J0 (kg m^2)'][row + l_items.index("Gimballs")] = 0
df['J0 (kg m^2)'][row + l_items.index("Engines")] = 0
df['J0 (kg m^2)'][row + l_items.index("Fuel")] = 0
df['J0 (kg m^2)'][row + l_items.index("Oxidizer")] = 0
if i < len(self.listOfSteps) - 1: # if not last step
# Interstage ( using formual for centroid of trapezoid)
df['J0 (kg m^2)'][row + l_items.index("Forward Skirt")] = df['Mass (kg)'][row + l_items.index("Forward Skirt")] * ( (pow(step.r,2) + pow(self.listOfSteps[i+1].r,2))/4 + pow(df['Height (m)'][row + l_items.index("Forward Skirt")],2)/18 * (1+(2*step.r*self.listOfSteps[i+1].r)/(pow(step.r + self.listOfSteps[i+1].r,2))))
elif i == len(self.listOfSteps) - 1: # if last step
df['J0 (kg m^2)'][row + l_items.index("Forward Skirt")] = df['Mass (kg)'][row + l_items.index("Forward Skirt")] * (pow(step.r,2)/2 + pow(df['Height (m)'][row + l_items.index("Forward Skirt")],2)/12)
df['J0 (kg m^2)'][pl_items.index("PAF")] = df['Mass (kg)'][pl_items.index("PAF")] * pow(step.r,2)/2
df['J0 (kg m^2)'][pl_items.index("Payload")] = df['Mass (kg)'][pl_items.index("Payload")] * pow(df['Height (m)'][pl_items.index("Payload")],2)/12
df['J0 (kg m^2)'][pl_items.index("PLF")] = df['Mass (kg)'][pl_items.index("PLF")] * (pow(step.r,2)/4 + pow(df['Height (m)'][pl_items.index("PLF")],2)/18)
row += len(l_items)
elif step.propulsion == 'Solid':
if i < len(self.listOfSteps) - 1: # if not last step
if step.parallel:
df['J0 (kg m^2)'][row + s_items.index("Nose Cone")] = df['Mass (kg)'][row + s_items.index("Nose Cone")] * (pow(step.r,2)/4 + pow(df['Height (m)'][row + s_items.index("Nose Cone")],2)/18)
df['J0 (kg m^2)'][row + s_items.index("Forward Skirt")] = df['Mass (kg)'][row + s_items.index("Forward Skirt")] * ( (pow(step.r,2) + pow(self.listOfSteps[i+1].r,2))/4 + pow(df['Height (m)'][row + s_items.index("Forward Skirt")],2)/18 * (1+(2*step.r*self.listOfSteps[i+1].r)/(pow(step.r + self.listOfSteps[i+1].r,2))))
elif i == len(self.listOfSteps) - 1: # if last step
df['J0 (kg m^2)'][row + s_items.index("Forward Skirt")] = df['Mass (kg)'][row + s_items.index("Forward Skirt")] - self.CM_full
df['J0 (kg m^2)'][pl_items.index("PAF")] = df['Mass (kg)'][pl_items.index("PAF")] * pow(step.r,2)/2
df['J0 (kg m^2)'][pl_items.index("Payload")] = df['Mass (kg)'][pl_items.index("Payload")] * pow(df['Height (m)'][pl_items.index("Payload")],2)/12
df['J0 (kg m^2)'][pl_items.index("PLF")] = df['Mass (kg)'][pl_items.index("PLF")] * (pow(step.r,2)/4 + pow(df['Height (m)'][pl_items.index("PLF")],2)/18)
df['J0 (kg m^2)'][row + s_items.index("Avionics")] = df['Mass (kg)'][row + s_items.index("Avionics")] * pow(step.r,2)/2
df['J0 (kg m^2)'][row + s_items.index("Wiring")] = df['Mass (kg)'][row + s_items.index("Wiring")] * pow(df['Height (m)'][row + s_items.index("Wiring")],2)/12
df['J0 (kg m^2)'][row + s_items.index("Pressurant Tank")] = df['Mass (kg)'][row + s_items.index("Pressurant Tank")] * pow(step.r,2)
df['J0 (kg m^2)'][row + s_items.index("SRM Dome Top")] = df['Mass (kg)'][row + s_items.index("SRM Dome Top")] * pow(step.r,2)
df['J0 (kg m^2)'][row + s_items.index("Solid Propellant Casing")] = df['Mass (kg)'][row + s_items.index("Solid Propellant Casing")] * ( pow(step.r,2)/2 + pow(df['Height (m)'][row + s_items.index("Solid Propellant Casing")],2)/12 )
df['J0 (kg m^2)'][row + s_items.index("SRM Dome Bottom")] = df['Mass (kg)'][row + s_items.index("SRM Dome Bottom")] * pow(step.r,2)
df['J0 (kg m^2)'][row + s_items.index("Solid Propellant Residual")] = 0
df['J0 (kg m^2)'][row + s_items.index("Aft Skirt")] = df['Mass (kg)'][row + s_items.index("Aft Skirt")] * ( pow(step.r,2) + pow(df['Height (m)'][row + s_items.index("Aft Skirt")],2)/12)
df['J0 (kg m^2)'][row + s_items.index("Gimballs")] = 0
df['J0 (kg m^2)'][row + s_items.index("Nozzle")] = 0
df['J0 (kg m^2)'][row + s_items.index("Solid Propellant")] = 0
row += len(s_items)
# init J0's - double check some values such as payload, fairing, propellant tanks etc
def initJ0s(self, df, pl_items, l_items, s_items):
row = len(pl_items)
for i in range(len(self.listOfSteps)):
step = self.listOfSteps[i]
if step.propulsion == "Liquid":
df['J0 (kg m^2)'][row + l_items.index("Avionics")] = self.J0ThinRing(df['Mass (kg)'][row + l_items.index("Avionics")], step.r)
df['J0 (kg m^2)'][row + l_items.index("Wiring")] = self.J0SolidRod(df['Mass (kg)'][row + l_items.index("Wiring")], df['Height (m)'][row + l_items.index("Wiring")])
df['J0 (kg m^2)'][row + l_items.index("Fuel Dome Top")] = self.J0ThinEllipsoid(df['Mass (kg)'][row + l_items.index("Fuel Dome Top")], step.r, step.dome_f[0])
df['J0 (kg m^2)'][row + l_items.index("Fuel Cylinder")] = self.J0ThinCyl(df['Mass (kg)'][row + l_items.index("Fuel Cylinder")], step.r, step.cyl_f[0])
df['J0 (kg m^2)'][row + l_items.index("Fuel Dome Bottom")] = self.J0ThinEllipsoid(df['Mass (kg)'][row + l_items.index("Fuel Dome Bottom")], step.r, step.dome_f[0])
SA_F_Tank = step.cyl_f[1] + 2 * step.dome_f[1]
m_ins_f = df['Mass (kg)'][row + l_items.index("Fuel Insulation")]
m_ins_f_dome = step.dome_f[1]/SA_F_Tank*m_ins_f
m_ins_f_cyl = step.cyl_f[1]/SA_F_Tank*m_ins_f
if m_ins_f == 0:
df['J0 (kg m^2)'][row + l_items.index("Fuel Insulation")] = 0
else:
df['J0 (kg m^2)'][row + l_items.index("Fuel Insulation")] = (2*m_ins_f_dome*self.J0ThinEllipsoid(m_ins_f_dome, step.r, step.dome_f[0]) + m_ins_f_cyl*self.J0ThinCyl(m_ins_f_cyl, step.r, step.cyl_f[0]))/m_ins_f
df['J0 (kg m^2)'][row + l_items.index("Fuel Residual")] = 0
df['J0 (kg m^2)'][row + l_items.index("Intertank")] = self.J0ThinCyl(df['Mass (kg)'][row + l_items.index("Intertank")], step.r, step.intertank[0])
df['J0 (kg m^2)'][row + l_items.index("Ox Dome Top")] = self.J0ThinEllipsoid(df['Mass (kg)'][row + l_items.index("Ox Dome Top")], step.r, step.dome_ox[0])
df['J0 (kg m^2)'][row + l_items.index("Ox Cylinder")] = self.J0ThinCyl(df['Mass (kg)'][row + l_items.index("Ox Cylinder")], step.r, step.cyl_ox[0])
df['J0 (kg m^2)'][row + l_items.index("Ox Dome Bottom")] = self.J0ThinEllipsoid(df['Mass (kg)'][row + l_items.index("Ox Dome Bottom")], step.r, step.dome_ox[0])
SA_Ox_Tank = step.cyl_ox[1] + 2 * step.dome_ox[1]
m_ins_ox = df['Mass (kg)'][row + l_items.index("Ox Insulation")]
m_ins_ox_dome = step.dome_ox[1]/SA_Ox_Tank*m_ins_ox
m_ins_ox_cyl = step.cyl_ox[1]/SA_Ox_Tank*m_ins_ox
df['J0 (kg m^2)'][row + l_items.index("Ox Insulation")] = (2*m_ins_ox_dome*self.J0ThinEllipsoid(m_ins_ox_dome, step.r, step.dome_ox[0]) + m_ins_ox_cyl*self.J0ThinCyl(m_ins_ox_cyl, step.r, step.cyl_ox[0]))/m_ins_ox
df['J0 (kg m^2)'][row + l_items.index("Ox Residual")] = 0
df['J0 (kg m^2)'][row + l_items.index("Pressurant Tank")] = self.J0ThinHemisphere(df['Mass (kg)'][row + l_items.index("Pressurant Tank")], step.r)
df['J0 (kg m^2)'][row + l_items.index("Aft Skirt")] = self.J0ThinCyl(df['Mass (kg)'][row + l_items.index("Aft Skirt")], step.r, step.aft_skirt[0])
df['J0 (kg m^2)'][row + l_items.index("Thrust Structure")] = 0
df['J0 (kg m^2)'][row + l_items.index("Gimballs")] = 0
df['J0 (kg m^2)'][row + l_items.index("Engines")] = 0
df['J0 (kg m^2)'][row + l_items.index("Fuel")] = 0
df['J0 (kg m^2)'][row + l_items.index("Oxidizer")] = 0
if i < len(self.listOfSteps) - 1: # if not last step
# Interstage ( using formual for centroid of trapezoid)
df['J0 (kg m^2)'][row + l_items.index("Forward Skirt")] = self.J0ThinTrap(df['Mass (kg)'][row + l_items.index("Forward Skirt")], step.r, self.listOfSteps[i+1].r, df['Height (m)'][row + l_items.index("Forward Skirt")])
elif i == len(self.listOfSteps) - 1: # if last step
df['J0 (kg m^2)'][row + l_items.index("Forward Skirt")] = self.J0ThinCyl(df['Mass (kg)'][row + l_items.index("Forward Skirt")], step.r, step.fwd_skirt[0])
df['J0 (kg m^2)'][pl_items.index("PAF")] = self.J0ThinRing(df['Mass (kg)'][pl_items.index("PAF")], step.r)
df['J0 (kg m^2)'][pl_items.index("Payload")] = self.J0SolidCyl(df['Mass (kg)'][pl_items.index("Payload")], step.r, step.fairing[0][0])
last_step = self.listOfSteps[len(self.listOfSteps)-1]
SA_PLF = sum(last_step.fairing[1])
m_PLF = df['Mass (kg)'][pl_items.index("PLF")]
m_PLF_cyl = step.fairing[1][0]/SA_PLF*m_PLF
m_PLF_cone = step.fairing[1][1]/SA_PLF*m_PLF
df['J0 (kg m^2)'][pl_items.index("PLF")] = (m_PLF_cyl*self.J0ThinCyl(m_PLF_cyl, step.r, step.fairing[0][0]) + m_PLF_cone*self.J0ThinCone(m_PLF_cone, step.r, step.fairing[0][1]))/m_PLF
row += len(l_items)
elif step.propulsion == 'Solid':
if i < len(self.listOfSteps) - 1: # if not last step
if step.parallel:
df['J0 (kg m^2)'][row + s_items.index("Nose Cone")] = self.J0ThinCone(df['Mass (kg)'][row + s_items.index("Nose Cone")], step.r, step.fairing[0])
df['J0 (kg m^2)'][row + s_items.index("Forward Skirt")] = self.J0ThinTrap(df['Mass (kg)'][row + s_items.index("Forward Skirt")], step.r, self.listOfSteps[i+1].r, df['Height (m)'][row + s_items.index("Forward Skirt")])
elif i == len(self.listOfSteps) - 1: # if last step
df['J0 (kg m^2)'][row + s_items.index("Forward Skirt")] = self.J0ThinCyl(df['Mass (kg)'][row + s_items.index("Forward Skirt")], step.r, step.fwd_skirt[0])
df['J0 (kg m^2)'][pl_items.index("PAF")] = self.J0ThinRing(df['Mass (kg)'][pl_items.index("PAF")], step.r)
df['J0 (kg m^2)'][pl_items.index("Payload")] = self.J0SolidCyl(df['Mass (kg)'][pl_items.index("Payload")], step.r, step.fairing[0][0])
m_PLF = df['Mass (kg)'][pl_items.index("PLF")]
m_PLF_cyl = step.fairing[1][0]/SA_PLF*m_PLF
m_PLF_cone = step.fairing[1][1]/SA_PLF*m_PLF
df['J0 (kg m^2)'][pl_items.index("PLF")] = (m_PLF_cyl*self.J0ThinCyl(m_PLF_cyl, step.r, step.fairing[0][0]) + m_PLF_cone*self.J0ThinCone(m_PLF_cone, step.r, step.fairing[0][1]))/m_PLF
df['J0 (kg m^2)'][row + s_items.index("Avionics")] = self.J0ThinRing(df['Mass (kg)'][row + s_items.index("Avionics")], step.r)
df['J0 (kg m^2)'][row + s_items.index("Wiring")] = self.J0SolidRod(df['Mass (kg)'][row + s_items.index("Wiring")], df['Height (m)'][row + s_items.index("Wiring")])
df['J0 (kg m^2)'][row + s_items.index("Pressurant Tank")] = 2*self.J0ThinHemisphere(df['Mass (kg)'][row + s_items.index("Pressurant Tank")], step.r)
df['J0 (kg m^2)'][row + s_items.index("SRM Dome Top")] = self.J0ThinEllipsoid(df['Mass (kg)'][row + s_items.index("SRM Dome Top")], step.r, step.dome_f[0])
df['J0 (kg m^2)'][row + s_items.index("Solid Propellant Casing")] = self.J0ThinCyl(df['Mass (kg)'][row + s_items.index("Solid Propellant Casing")], step.r, step.srm_casing[0])
df['J0 (kg m^2)'][row + s_items.index("SRM Dome Bottom")] = self.J0ThinEllipsoid(df['Mass (kg)'][row + s_items.index("SRM Dome Bottom")], step.r, step.dome_f[0])
df['J0 (kg m^2)'][row + s_items.index("Solid Propellant Residual")] = 0
df['J0 (kg m^2)'][row + s_items.index("Aft Skirt")] = self.J0ThinCyl(df['Mass (kg)'][row + s_items.index("Aft Skirt")], step.r, step.aft_skirt[0])
df['J0 (kg m^2)'][row + s_items.index("Gimballs")] = 0
df['J0 (kg m^2)'][row + s_items.index("Nozzle")] = 0
SA_SRM = step.dome_f[1]*2 + step.srm_casing[1]
m_solid_prop = df['Mass (kg)'][row + s_items.index("Solid Propellant")]
m_dome = step.dome_f[1]/SA_SRM*m_solid_prop
m_casing = step.srm_casing[1]/SA_SRM*m_solid_prop
# J0_solid propellant = (2*m_dome*J0_dome + m_casing*J0_casing)/m_total
df['J0 (kg m^2)'][row + s_items.index("Solid Propellant")] = (2*m_dome*self.J0SolidEllipsoid(m_dome, step.r, step.dome_f[0]) + m_casing*self.J0SolidCyl(m_casing, step.r, step.srm_casing[0]))/m_solid_prop
row += len(s_items)
def initmCMs(self, df, pl_items, l_items, s_items):
row = len(pl_items)
for i in range(len(self.listOfSteps)):
step = self.listOfSteps[i]
if step.propulsion == "Liquid":
df['m*CM^2 (kg m^2)'][row + l_items.index("Avionics")] = df['Mass (kg)'][row + l_items.index("Avionics")] * pow(df['Distance from CM (m)'][row + l_items.index("Avionics")],2)
df['m*CM^2 (kg m^2)'][row + l_items.index("Wiring")] = df['Mass (kg)'][row + l_items.index("Wiring")] * pow(df['Distance from CM (m)'][row + l_items.index("Wiring")],2)
df['m*CM^2 (kg m^2)'][row + l_items.index("Fuel Dome Top")] = df['Mass (kg)'][row + l_items.index("Fuel Dome Top")] * pow(df['Distance from CM (m)'][row + l_items.index("Fuel Dome Top")],2)
df['m*CM^2 (kg m^2)'][row + l_items.index("Fuel Cylinder")] = df['Mass (kg)'][row + l_items.index("Fuel Cylinder")] * pow(df['Distance from CM (m)'][row + l_items.index("Fuel Cylinder")],2)
df['m*CM^2 (kg m^2)'][row + l_items.index("Fuel Dome Bottom")] = df['Mass (kg)'][row + l_items.index("Fuel Dome Bottom")] * pow(df['Distance from CM (m)'][row + l_items.index("Fuel Dome Bottom")],2)
df['m*CM^2 (kg m^2)'][row + l_items.index("Fuel Insulation")] = df['Mass (kg)'][row + l_items.index("Fuel Insulation")] * pow(df['Distance from CM (m)'][row + l_items.index("Fuel Insulation")],2)
df['m*CM^2 (kg m^2)'][row + l_items.index("Fuel Residual")] = df['Mass (kg)'][row + l_items.index("Fuel Residual")] * pow(df['Distance from CM (m)'][row + l_items.index("Fuel Residual")],2)
df['m*CM^2 (kg m^2)'][row + l_items.index("Intertank")] = df['Mass (kg)'][row + l_items.index("Intertank")] * pow(df['Distance from CM (m)'][row + l_items.index("Intertank")],2)
df['m*CM^2 (kg m^2)'][row + l_items.index("Ox Dome Top")] = df['Mass (kg)'][row + l_items.index("Ox Dome Top")] * pow(df['Distance from CM (m)'][row + l_items.index("Ox Dome Top")],2)
df['m*CM^2 (kg m^2)'][row + l_items.index("Ox Cylinder")] = df['Mass (kg)'][row + l_items.index("Ox Cylinder")] * pow(df['Distance from CM (m)'][row + l_items.index("Ox Cylinder")],2)
df['m*CM^2 (kg m^2)'][row + l_items.index("Ox Dome Bottom")] = df['Mass (kg)'][row + l_items.index("Ox Dome Bottom")] * pow(df['Distance from CM (m)'][row + l_items.index("Ox Dome Bottom")],2)
df['m*CM^2 (kg m^2)'][row + l_items.index("Ox Insulation")] = df['Mass (kg)'][row + l_items.index("Ox Insulation")] * pow(df['Distance from CM (m)'][row + l_items.index("Ox Insulation")],2)
df['m*CM^2 (kg m^2)'][row + l_items.index("Ox Residual")] = df['Mass (kg)'][row + l_items.index("Ox Residual")] * pow(df['Distance from CM (m)'][row + l_items.index("Ox Residual")],2)
df['m*CM^2 (kg m^2)'][row + l_items.index("Pressurant Tank")] = df['Mass (kg)'][row + l_items.index("Pressurant Tank")] * pow(df['Distance from CM (m)'][row + l_items.index("Pressurant Tank")],2)
df['m*CM^2 (kg m^2)'][row + l_items.index("Aft Skirt")] = df['Mass (kg)'][row + l_items.index("Aft Skirt")] * pow(df['Distance from CM (m)'][row + l_items.index("Aft Skirt")],2)
df['m*CM^2 (kg m^2)'][row + l_items.index("Thrust Structure")] = df['Mass (kg)'][row + l_items.index("Thrust Structure")] * pow(df['Distance from CM (m)'][row + l_items.index("Thrust Structure")],2)
df['m*CM^2 (kg m^2)'][row + l_items.index("Gimballs")] = df['Mass (kg)'][row + l_items.index("Gimballs")] * pow(df['Distance from CM (m)'][row + l_items.index("Gimballs")],2)
df['m*CM^2 (kg m^2)'][row + l_items.index("Engines")] = df['Mass (kg)'][row + l_items.index("Engines")] * pow(df['Distance from CM (m)'][row + l_items.index("Engines")],2)
df['m*CM^2 (kg m^2)'][row + l_items.index("Fuel")] = df['Mass (kg)'][row + l_items.index("Fuel")] * pow(df['Distance from CM (m)'][row + l_items.index("Fuel")],2)
df['m*CM^2 (kg m^2)'][row + l_items.index("Oxidizer")] = df['Mass (kg)'][row + l_items.index("Oxidizer")] * pow(df['Distance from CM (m)'][row + l_items.index("Oxidizer")],2)
if i < len(self.listOfSteps) - 1: # if not last step
# Interstage ( using formual for centroid of trapezoid)
df['m*CM^2 (kg m^2)'][row + l_items.index("Forward Skirt")] = df['Mass (kg)'][row + l_items.index("Forward Skirt")] * pow(df['Distance from CM (m)'][row + l_items.index("Forward Skirt")],2)
elif i == len(self.listOfSteps) - 1: # if last step
df['m*CM^2 (kg m^2)'][row + l_items.index("Forward Skirt")] = df['Mass (kg)'][row + l_items.index("Forward Skirt")] * pow(df['Distance from CM (m)'][row + l_items.index("Forward Skirt")],2)
df['m*CM^2 (kg m^2)'][pl_items.index("PAF")] = df['Mass (kg)'][pl_items.index("PAF")] * pow(df['Distance from CM (m)'][pl_items.index("PAF")],2)
df['m*CM^2 (kg m^2)'][pl_items.index("Payload")] = df['Mass (kg)'][pl_items.index("Payload")] * pow(df['Distance from CM (m)'][pl_items.index("Payload")],2)
df['m*CM^2 (kg m^2)'][pl_items.index("PLF")] = df['Mass (kg)'][pl_items.index("PLF")] * pow(df['Distance from CM (m)'][pl_items.index("PLF")],2)
row += len(l_items)
elif step.propulsion == 'Solid':
if i < len(self.listOfSteps) - 1: # if not last step
if step.parallel:
df['m*CM^2 (kg m^2)'][row + s_items.index("Nose Cone")] = df['Mass (kg)'][row + s_items.index("Nose Cone")] * pow(df['Distance from CM (m)'][row + s_items.index("Nose Cone")],2)
df['m*CM^2 (kg m^2)'][row + s_items.index("Forward Skirt")] = df['Mass (kg)'][row + s_items.index("Forward Skirt")] * pow(df['Distance from CM (m)'][row + s_items.index("Forward Skirt")],2)
elif i == len(self.listOfSteps) - 1: # if last step
df['m*CM^2 (kg m^2)'][row + s_items.index("Forward Skirt")] = df['Mass (kg)'][row + s_items.index("Forward Skirt")] * pow(df['Distance from CM (m)'][row + s_items.index("Forward Skirt")],2)
df['m*CM^2 (kg m^2)'][pl_items.index("PAF")] = df['Mass (kg)'][pl_items.index("PAF")] * pow(df['Distance from CM (m)'][pl_items.index("PAF")],2)
df['m*CM^2 (kg m^2)'][pl_items.index("Payload")] = df['Mass (kg)'][pl_items.index("Payload")] * pow(df['Distance from CM (m)'][pl_items.index("Payload")],2)
df['m*CM^2 (kg m^2)'][pl_items.index("PLF")] = df['Mass (kg)'][pl_items.index("PLF")] * pow(df['Distance from CM (m)'][pl_items.index("PLF")],2)
df['m*CM^2 (kg m^2)'][row + s_items.index("Avionics")] = df['Mass (kg)'][row + s_items.index("Avionics")] * pow(df['Distance from CM (m)'][row + s_items.index("Avionics")],2)
df['m*CM^2 (kg m^2)'][row + s_items.index("Wiring")] = df['Mass (kg)'][row + s_items.index("Wiring")] * pow(df['Distance from CM (m)'][row + s_items.index("Wiring")],2)
df['m*CM^2 (kg m^2)'][row + s_items.index("Pressurant Tank")] = df['Mass (kg)'][row + s_items.index("Pressurant Tank")] * pow(df['Distance from CM (m)'][row + s_items.index("Pressurant Tank")],2)
df['m*CM^2 (kg m^2)'][row + s_items.index("SRM Dome Top")] = df['Mass (kg)'][row + s_items.index("SRM Dome Top")] * pow(df['Distance from CM (m)'][row + s_items.index("SRM Dome Top")],2)
df['m*CM^2 (kg m^2)'][row + s_items.index("Solid Propellant Casing")] = df['Mass (kg)'][row + s_items.index("Solid Propellant Casing")] * pow(df['Distance from CM (m)'][row + s_items.index("Solid Propellant Casing")],2)
df['m*CM^2 (kg m^2)'][row + s_items.index("SRM Dome Bottom")] = df['Mass (kg)'][row + s_items.index("SRM Dome Bottom")] * pow(df['Distance from CM (m)'][row + s_items.index("SRM Dome Bottom")],2)
df['m*CM^2 (kg m^2)'][row + s_items.index("Solid Propellant Residual")] = df['Mass (kg)'][row + s_items.index("Solid Propellant Residual")] * pow(df['Distance from CM (m)'][row + s_items.index("Solid Propellant Residual")],2)
df['m*CM^2 (kg m^2)'][row + s_items.index("Aft Skirt")] = df['Mass (kg)'][row + s_items.index("Aft Skirt")] * pow(df['Distance from CM (m)'][row + s_items.index("Aft Skirt")],2)
df['m*CM^2 (kg m^2)'][row + s_items.index("Gimballs")] = df['Mass (kg)'][row + s_items.index("Gimballs")] * pow(df['Distance from CM (m)'][row + s_items.index("Gimballs")],2)
df['m*CM^2 (kg m^2)'][row + s_items.index("Nozzle")] = df['Mass (kg)'][row + s_items.index("Nozzle")] * pow(df['Distance from CM (m)'][row + s_items.index("Nozzle")],2)
df['m*CM^2 (kg m^2)'][row + s_items.index("Solid Propellant")] = df['Mass (kg)'][row + s_items.index("Solid Propellant")] * pow(df['Distance from CM (m)'][row + s_items.index("Solid Propellant")],2)
row += len(s_items)
def initJPitchYawOld(self, df, pl_items, l_items, s_items):
row = len(pl_items)
for i in range(len(self.listOfSteps)):
step = self.listOfSteps[i]
if step.propulsion == "Liquid":
df['Jpitch/yaw'][row + l_items.index("Avionics")] = df['m*CM^2 (kg m^2)'][row + l_items.index("Avionics")] + df['Distance from CM (m)'][row + l_items.index("Avionics")]
df['Jpitch/yaw'][row + l_items.index("Wiring")] = df['m*CM^2 (kg m^2)'][row + l_items.index("Wiring")] + df['Distance from CM (m)'][row + l_items.index("Wiring")]
df['Jpitch/yaw'][row + l_items.index("Fuel Dome Top")] = df['m*CM^2 (kg m^2)'][row + l_items.index("Fuel Dome Top")] + df['Distance from CM (m)'][row + l_items.index("Fuel Dome Top")]
df['Jpitch/yaw'][row + l_items.index("Fuel Cylinder")] = df['m*CM^2 (kg m^2)'][row + l_items.index("Fuel Cylinder")] + df['Distance from CM (m)'][row + l_items.index("Fuel Cylinder")]
df['Jpitch/yaw'][row + l_items.index("Fuel Dome Bottom")] = df['m*CM^2 (kg m^2)'][row + l_items.index("Fuel Dome Bottom")] + df['Distance from CM (m)'][row + l_items.index("Fuel Dome Bottom")]
df['Jpitch/yaw'][row + l_items.index("Fuel Insulation")] = df['m*CM^2 (kg m^2)'][row + l_items.index("Fuel Insulation")] + df['Distance from CM (m)'][row + l_items.index("Fuel Insulation")]
df['Jpitch/yaw'][row + l_items.index("Fuel Residual")] = df['m*CM^2 (kg m^2)'][row + l_items.index("Fuel Residual")] + df['Distance from CM (m)'][row + l_items.index("Fuel Residual")]
df['Jpitch/yaw'][row + l_items.index("Intertank")] = df['m*CM^2 (kg m^2)'][row + l_items.index("Intertank")] + df['Distance from CM (m)'][row + l_items.index("Intertank")]
df['Jpitch/yaw'][row + l_items.index("Ox Dome Top")] = df['m*CM^2 (kg m^2)'][row + l_items.index("Ox Dome Top")] + df['Distance from CM (m)'][row + l_items.index("Ox Dome Top")]
df['Jpitch/yaw'][row + l_items.index("Ox Cylinder")] = df['m*CM^2 (kg m^2)'][row + l_items.index("Ox Cylinder")] + df['Distance from CM (m)'][row + l_items.index("Ox Cylinder")]
df['Jpitch/yaw'][row + l_items.index("Ox Dome Bottom")] = df['m*CM^2 (kg m^2)'][row + l_items.index("Ox Dome Bottom")] + df['Distance from CM (m)'][row + l_items.index("Ox Dome Bottom")]
df['Jpitch/yaw'][row + l_items.index("Ox Insulation")] = df['m*CM^2 (kg m^2)'][row + l_items.index("Ox Insulation")] + df['Distance from CM (m)'][row + l_items.index("Ox Insulation")]
df['Jpitch/yaw'][row + l_items.index("Ox Residual")] = df['m*CM^2 (kg m^2)'][row + l_items.index("Ox Residual")] + df['Distance from CM (m)'][row + l_items.index("Ox Residual")]
df['Jpitch/yaw'][row + l_items.index("Pressurant Tank")] = df['m*CM^2 (kg m^2)'][row + l_items.index("Pressurant Tank")] + df['Distance from CM (m)'][row + l_items.index("Pressurant Tank")]
df['Jpitch/yaw'][row + l_items.index("Aft Skirt")] = df['m*CM^2 (kg m^2)'][row + l_items.index("Aft Skirt")] + df['Distance from CM (m)'][row + l_items.index("Aft Skirt")]
df['Jpitch/yaw'][row + l_items.index("Thrust Structure")] = df['m*CM^2 (kg m^2)'][row + l_items.index("Thrust Structure")] + df['Distance from CM (m)'][row + l_items.index("Thrust Structure")]
df['Jpitch/yaw'][row + l_items.index("Gimballs")] = df['m*CM^2 (kg m^2)'][row + l_items.index("Gimballs")] + df['Distance from CM (m)'][row + l_items.index("Gimballs")]
df['Jpitch/yaw'][row + l_items.index("Engines")] = df['m*CM^2 (kg m^2)'][row + l_items.index("Engines")] + df['Distance from CM (m)'][row + l_items.index("Engines")]
df['Jpitch/yaw'][row + l_items.index("Fuel")] = df['m*CM^2 (kg m^2)'][row + l_items.index("Fuel")] + df['Distance from CM (m)'][row + l_items.index("Fuel")]
df['Jpitch/yaw'][row + l_items.index("Oxidizer")] = df['m*CM^2 (kg m^2)'][row + l_items.index("Oxidizer")] + df['Distance from CM (m)'][row + l_items.index("Oxidizer")]
if i < len(self.listOfSteps) - 1: # if not last step
# Interstage ( using formual for centroid of trapezoid)
df['Jpitch/yaw'][row + l_items.index("Forward Skirt")] = df['m*CM^2 (kg m^2)'][row + l_items.index("Forward Skirt")] + df['Distance from CM (m)'][row + l_items.index("Forward Skirt")]
elif i == len(self.listOfSteps) - 1: # if last step
df['Jpitch/yaw'][row + l_items.index("Forward Skirt")] = df['m*CM^2 (kg m^2)'][row + l_items.index("Forward Skirt")] + df['Distance from CM (m)'][row + l_items.index("Forward Skirt")]
df['Jpitch/yaw'][pl_items.index("PAF")] = df['m*CM^2 (kg m^2)'][pl_items.index("PAF")] + df['Distance from CM (m)'][pl_items.index("PAF")]
df['Jpitch/yaw'][pl_items.index("Payload")] = df['m*CM^2 (kg m^2)'][pl_items.index("Payload")] + df['Distance from CM (m)'][pl_items.index("Payload")]
df['Jpitch/yaw'][pl_items.index("PLF")] = df['m*CM^2 (kg m^2)'][pl_items.index("PLF")] + df['Distance from CM (m)'][pl_items.index("PLF")]
row += len(l_items)
elif step.propulsion == 'Solid':
if i < len(self.listOfSteps) - 1: # if not last step
if step.parallel:
df['Jpitch/yaw'][row + s_items.index("Nose Cone")] = df['m*CM^2 (kg m^2)'][row + s_items.index("Nose Cone")] + df['Distance from CM (m)'][row + s_items.index("Nose Cone")]
df['Jpitch/yaw'][row + s_items.index("Forward Skirt")] = df['m*CM^2 (kg m^2)'][row + s_items.index("Forward Skirt")] + df['Distance from CM (m)'][row + s_items.index("Forward Skirt")]
elif i == len(self.listOfSteps) - 1: # if last step
df['Jpitch/yaw'][row + s_items.index("Forward Skirt")] = df['m*CM^2 (kg m^2)'][row + s_items.index("Forward Skirt")] + df['Distance from CM (m)'][row + s_items.index("Forward Skirt")]
df['Jpitch/yaw'][pl_items.index("PAF")] = df['m*CM^2 (kg m^2)'][pl_items.index("PAF")] + df['Distance from CM (m)'][pl_items.index("PAF")]
df['Jpitch/yaw'][pl_items.index("Payload")] = df['m*CM^2 (kg m^2)'][pl_items.index("Payload")] + df['Distance from CM (m)'][pl_items.index("Payload")]
df['Jpitch/yaw'][pl_items.index("PLF")] = df['m*CM^2 (kg m^2)'][pl_items.index("PLF")] + df['Distance from CM (m)'][pl_items.index("PLF")]
df['Jpitch/yaw'][row + s_items.index("Avionics")] = df['m*CM^2 (kg m^2)'][row + s_items.index("Avionics")] + df['Distance from CM (m)'][row + s_items.index("Avionics")]
df['Jpitch/yaw'][row + s_items.index("Wiring")] = df['m*CM^2 (kg m^2)'][row + s_items.index("Wiring")] + df['Distance from CM (m)'][row + s_items.index("Wiring")]
df['Jpitch/yaw'][row + s_items.index("Pressurant Tank")] = df['m*CM^2 (kg m^2)'][row + s_items.index("Pressurant Tank")] + df['Distance from CM (m)'][row + s_items.index("Pressurant Tank")]
df['Jpitch/yaw'][row + s_items.index("SRM Dome Top")] = df['m*CM^2 (kg m^2)'][row + s_items.index("SRM Dome Top")] + df['Distance from CM (m)'][row + s_items.index("SRM Dome Top")]
df['Jpitch/yaw'][row + s_items.index("Solid Propellant Casing")] = df['m*CM^2 (kg m^2)'][row + s_items.index("Solid Propellant Casing")] + df['Distance from CM (m)'][row + s_items.index("Solid Propellant Casing")]
df['Jpitch/yaw'][row + s_items.index("SRM Dome Bottom")] = df['m*CM^2 (kg m^2)'][row + s_items.index("SRM Dome Bottom")] + df['Distance from CM (m)'][row + s_items.index("SRM Dome Bottom")]
df['Jpitch/yaw'][row + s_items.index("Solid Propellant Residual")] = df['m*CM^2 (kg m^2)'][row + s_items.index("Solid Propellant Residual")] + df['Distance from CM (m)'][row + s_items.index("Solid Propellant Residual")]
df['Jpitch/yaw'][row + s_items.index("Aft Skirt")] = df['m*CM^2 (kg m^2)'][row + s_items.index("Aft Skirt")] + df['Distance from CM (m)'][row + s_items.index("Aft Skirt")]
df['Jpitch/yaw'][row + s_items.index("Gimballs")] = df['m*CM^2 (kg m^2)'][row + s_items.index("Gimballs")] + df['Distance from CM (m)'][row + s_items.index("Gimballs")]
df['Jpitch/yaw'][row + s_items.index("Nozzle")] = df['m*CM^2 (kg m^2)'][row + s_items.index("Nozzle")] + df['Distance from CM (m)'][row + s_items.index("Nozzle")]
df['Jpitch/yaw'][row + s_items.index("Solid Propellant")] = df['m*CM^2 (kg m^2)'][row + s_items.index("Solid Propellant")] + df['Distance from CM (m)'][row + s_items.index("Solid Propellant")]
row += len(s_items)
def initJPitchYaw(self, df, pl_items, l_items, s_items):
row = len(pl_items)
for i in range(len(self.listOfSteps)):
step = self.listOfSteps[i]
if step.propulsion == "Liquid":
df['Jpitch/yaw'][row + l_items.index("Avionics")] = df['m*CM^2 (kg m^2)'][row + l_items.index("Avionics")] + df['J0 (kg m^2)'][row + l_items.index("Avionics")]
df['Jpitch/yaw'][row + l_items.index("Wiring")] = df['m*CM^2 (kg m^2)'][row + l_items.index("Wiring")] + df['J0 (kg m^2)'][row + l_items.index("Wiring")]
df['Jpitch/yaw'][row + l_items.index("Fuel Dome Top")] = df['m*CM^2 (kg m^2)'][row + l_items.index("Fuel Dome Top")] + df['J0 (kg m^2)'][row + l_items.index("Fuel Dome Top")]
df['Jpitch/yaw'][row + l_items.index("Fuel Cylinder")] = df['m*CM^2 (kg m^2)'][row + l_items.index("Fuel Cylinder")] + df['J0 (kg m^2)'][row + l_items.index("Fuel Cylinder")]
df['Jpitch/yaw'][row + l_items.index("Fuel Dome Bottom")] = df['m*CM^2 (kg m^2)'][row + l_items.index("Fuel Dome Bottom")] + df['J0 (kg m^2)'][row + l_items.index("Fuel Dome Bottom")]
df['Jpitch/yaw'][row + l_items.index("Fuel Insulation")] = df['m*CM^2 (kg m^2)'][row + l_items.index("Fuel Insulation")] + df['J0 (kg m^2)'][row + l_items.index("Fuel Insulation")]
df['Jpitch/yaw'][row + l_items.index("Fuel Residual")] = df['m*CM^2 (kg m^2)'][row + l_items.index("Fuel Residual")] + df['J0 (kg m^2)'][row + l_items.index("Fuel Residual")]
df['Jpitch/yaw'][row + l_items.index("Intertank")] = df['m*CM^2 (kg m^2)'][row + l_items.index("Intertank")] + df['J0 (kg m^2)'][row + l_items.index("Intertank")]
df['Jpitch/yaw'][row + l_items.index("Ox Dome Top")] = df['m*CM^2 (kg m^2)'][row + l_items.index("Ox Dome Top")] + df['J0 (kg m^2)'][row + l_items.index("Ox Dome Top")]
df['Jpitch/yaw'][row + l_items.index("Ox Cylinder")] = df['m*CM^2 (kg m^2)'][row + l_items.index("Ox Cylinder")] + df['J0 (kg m^2)'][row + l_items.index("Ox Cylinder")]
df['Jpitch/yaw'][row + l_items.index("Ox Dome Bottom")] = df['m*CM^2 (kg m^2)'][row + l_items.index("Ox Dome Bottom")] + df['J0 (kg m^2)'][row + l_items.index("Ox Dome Bottom")]
df['Jpitch/yaw'][row + l_items.index("Ox Insulation")] = df['m*CM^2 (kg m^2)'][row + l_items.index("Ox Insulation")] + df['J0 (kg m^2)'][row + l_items.index("Ox Insulation")]