1
- from generalEquations import *
2
- from libs .spec_creator import *
3
- from libs .rocketEngine import *
4
- from libs .stage import *
5
- import libs .vehicle
6
- import libs .vehicleFactory
7
- import libs .velocity
1
+ import generalEquations as equ
2
+ from libs .spec_manager import create_specs , get_json_file_data
3
+ from libs .rocketEngine import RocketEngine
4
+ from libs .stage import Stage
5
+ from libs .vehicleFactory import VehicleFactory
6
+ from libs import velocity
8
7
from libs .query import Query as q
9
8
import numpy as np
9
+ from colorama import Fore , Style
10
10
11
11
12
12
def prompt_thrust_at_alt ():
13
- print "Thrust at alt Calculator"
14
- alt = float (raw_input ("Alt? " ))
15
- engines = libs . vehicleFactory . VehicleFactory .load_available_engines ()
16
- engine_list = []
17
- n = 1
18
- for key , value in engines .items ():
19
- engine_list .append (value )
20
- print ("{}) {}" .format (n , key ))
21
- n += 1
22
-
23
- engine_num = q .query_int ("Select an engine number: " , None , 1 , n - 1 )
24
- selected_engine = engine_list [engine_num - 1 ]
25
- engine_num = q .query_int ("How many? " , None , 1 , 100 )
26
- selected_engine ["engine_count" ] = engine_num
27
- engine = libs . rocketEngine . RocketEngine .factory (selected_engine )
28
- throt = q .query_min_max ("Throttle? " )
29
- engine .setThrottleOverride (throt )
30
- engine .setThrottleOverride (throt )
31
- print engine .thrustAtAlt (alt )
13
+ print ( "Thrust at alt Calculator" )
14
+ alt = float (input ("Alt? " ))
15
+ engines = VehicleFactory .load_available_engines ()
16
+ engine_list = []
17
+ n = 1
18
+ for key , value in engines .items ():
19
+ engine_list .append (value )
20
+ print ("{}) {}" .format (n , key ))
21
+ n += 1
22
+
23
+ engine_num = q .query_int ("Select an engine number: " , None , 1 , n - 1 )
24
+ selected_engine = engine_list [engine_num - 1 ]
25
+ engine_num = q .query_int ("How many? " , None , 1 , 100 )
26
+ selected_engine ["engine_count" ] = engine_num
27
+ engine = RocketEngine .factory (selected_engine )
28
+ throt = q .query_min_max ("Throttle? " )
29
+ engine .setThrottleOverride (throt )
30
+ engine .setThrottleOverride (throt )
31
+ print ( engine .thrustAtAlt (alt ) )
32
32
33
33
34
34
def prompt_PATM ():
35
- print "Percent of Atm Pressure Calculator"
36
- alt = float (raw_input ("Alt? " ))
37
- print percentOfAtmosphericPressure (alt )
35
+ print ("Percent of Atm Pressure Calculator" )
36
+ alt = float (input ("Alt? " ))
37
+ print (equ .percentOfAtmosphericPressure (alt ))
38
+
38
39
39
40
def prompt_vac ():
40
- print "Percent of Atm Vac Calculator"
41
- alt = float (raw_input ("Alt? " ))
42
- print percentOfVac (alt )
41
+ print ("Percent of Atm Vac Calculator" )
42
+ alt = float (input ("Alt? " ))
43
+ print (equ .percentOfVac (alt ))
44
+
43
45
44
46
def prompt_big_G ():
45
- print "Big G Calculator"
46
- V_h = float (raw_input ("Horizontal Velocity? " ))
47
- alt = float (raw_input ("Alt? " ))
48
- print bigG (V_h , velocity .Velocity .get_orbital (alt ))
47
+ print ("Big G Calculator" )
48
+ V_h = float (input ("Horizontal Velocity? " ))
49
+ alt = float (input ("Alt? " ))
50
+ print (equ .bigG (V_h , velocity .Velocity .get_orbital (alt )))
51
+
49
52
50
53
def prompt_ADC ():
51
- print "ADC Calculator"
52
- V_as = float (raw_input ("Air Speed Velocity? " ))
53
- alt = float (raw_input ("Alt? " ))
54
- adc_K = float (raw_input ("ADC K? " ))
55
- print ADC (V_as , alt , adc_K )
54
+ print ( "ADC Calculator" )
55
+ V_as = float (input ("Air Speed Velocity? " ))
56
+ alt = float (input ("Alt? " ))
57
+ adc_K = float (input ("ADC K? " ))
58
+ print ( equ . ADC (V_as , alt , adc_K ) )
56
59
57
60
58
61
def prompt_row ():
59
- first_row = {
60
- "alt" :
61
- [
62
- {"type" : "float" },
63
- {"promt" : "Enter alt: " }
64
- ],
65
- "prior_alt" :
66
- [
67
- {"type" : "float" },
68
- {"prompt" : "Enter the prior alt: " }
69
- ],
70
- "time_inc" :
71
- [
72
- {"type" : "float" },
73
- {"prompt" : "Enter the time increment: " }
74
- ],
75
- "adc_guess" :
76
- [
77
- {"type" : "float" },
78
- {"prompt" : "Guess the ADC: " }
79
- ],
80
- "thrust" :
81
- [
82
- {"type" : "float" },
83
- {"prompt" : "Enter the thrust: " }
84
- ],
85
- "weight" :
86
- [
87
- {"type" : "float" },
88
- {"prompt" : "Enter the weight: " }
89
- ],
90
- "error" :
91
- [
92
- {"type" : "float" },
93
- {"prompt" : "Enter the prior error: " }
94
- ],
95
- "A_v" :
96
- [
97
- {"type" : "string" },
98
- {"prompt" : "Assign the A_v or enter \" a\" to assign all A to A_V: " }
99
- ],
100
- "A_h_prior" :
101
- [
102
- {"type" : "float" },
103
- {"prompt" : "Enter the prior A_h: " }
104
- ],
105
- "V_h_prior" :
106
- [
107
- {"type" : "float" },
108
- {"prompt" : "Enter the prior V_h: " }
109
- ],
110
- "V_v_prior" :
111
- [
112
- {"type" : "float" },
113
- {"prompt" : "Enter the prior V_v: " }
114
- ]
115
- }
116
- loop_rows = {
117
- "time_inc" :
118
- [
119
- {"type" : "float" },
120
- {"prompt" : "Enter the time increment: " }
121
- ],
122
- "adc_guess" :
123
- [
124
- {"type" : "float" },
125
- {"prompt" : "Guess the ADC: " }
126
- ],
127
- "thrust" :
128
- [
129
- {"type" : "float" },
130
- {"prompt" : "Enter the thrust: " }
131
- ],
132
- "weight" :
133
- [
134
- {"type" : "float" },
135
- {"prompt" : "Enter the weight: " }
136
- ],
137
- "A_v" :
138
- [
139
- {"type" : "string" },
140
- {"prompt" : "Assign the A_v or enter \" a\" to assign all A to A_V: " }
141
- ]
142
- }
62
+ first_row = {
63
+ "alt" : [{"type" : "float" }, {"promt" : "Enter alt: " }],
64
+ "prior_alt" : [{"type" : "float" }, {"prompt" : "Enter the prior alt: " }],
65
+ "time_inc" : [{"type" : "float" }, {"prompt" : "Enter the time increment: " }],
66
+ "adc_guess" : [{"type" : "float" }, {"prompt" : "Guess the ADC: " }],
67
+ "thrust" : [{"type" : "float" }, {"prompt" : "Enter the thrust: " }],
68
+ "weight" : [{"type" : "float" }, {"prompt" : "Enter the weight: " }],
69
+ "error" : [{"type" : "float" }, {"prompt" : "Enter the prior error: " }],
70
+ "A_v" : [
71
+ {"type" : "string" },
72
+ {"prompt" : 'Assign the A_v or enter "a" to assign all A to A_V: ' },
73
+ ],
74
+ "A_h_prior" : [{"type" : "float" }, {"prompt" : "Enter the prior A_h: " }],
75
+ "V_h_prior" : [{"type" : "float" }, {"prompt" : "Enter the prior V_h: " }],
76
+ "V_v_prior" : [{"type" : "float" }, {"prompt" : "Enter the prior V_v: " }],
77
+ }
78
+ loop_rows = {
79
+ "time_inc" : [{"type" : "float" }, {"prompt" : "Enter the time increment: " }],
80
+ "adc_guess" : [{"type" : "float" }, {"prompt" : "Guess the ADC: " }],
81
+ "thrust" : [{"type" : "float" }, {"prompt" : "Enter the thrust: " }],
82
+ "weight" : [{"type" : "float" }, {"prompt" : "Enter the weight: " }],
83
+ "A_v" : [
84
+ {"type" : "string" },
85
+ {"prompt" : 'Assign the A_v or enter "a" to assign all A to A_V: ' },
86
+ ],
87
+ }
88
+
143
89
144
90
def prompt_preburn ():
145
- spec_data = get_json_file_data ("specs" , "spec" , create_specs )
146
- alt = q .query_float ("What is the alt for the preburn? " )
147
- preburn = Stage ({})
148
- engines = []
149
- engine_rows = VehicleFactory .load_engine_data (spec_data ["engines" ])
150
- for engine_row in engine_rows :
151
- engine = RocketEngine .factory (engine_row )
152
- engine .set_fuel_source (preburn )
153
- engines .append (engine )
154
- start_time = q .query_float ("What is the {}'s start time (positive start times will be ignored for preburn)? " .format (engine .name ))
155
- if start_time < 0 :
156
- start_throt = q .query_min_max ("What is the starting throttle for {}" .format (engine .name ))
157
- target_throt = q .query_min_max ("What is the target throttle for {}" .format (engine .name ))
158
- # set each weight twice to set average weight
159
- engine .setThrottleOverride (start_throt )
160
- if engine .type == "Solid" :
161
- start_thrust = q .query_min_max ("What is the starting " + Fore .RED + "thrust for {}" .format (engine .name ) + Style .RESET_ALL , 0 , float ("inf" ))
162
- start_thrust = q .query_min_max ("What is the target " + Fore .RED + "thrust for {}" .format (engine .name ) + Style .RESET_ALL , 0 , float ("inf" ))
163
- engine .set_assigned_thrust_per_engine (start_thrust )
164
-
165
- time_inc = 0.01
166
- for i in np .arange (0 , abs (start_time ), time_inc ):
167
- for engine in engines :
168
- engine .burn_fuel (time_inc , alt )
169
- engine .setThrottle (target_throt , time_inc )
170
-
171
- total_burned = 0.0
172
- print preburn .fuel_used
173
- # select config file or select engines
174
- # ask for engine start times
175
- # for each engine preburn until time 0
176
- # report amount burned per engine group
177
- # report total burned
91
+ spec_data = get_json_file_data ("specs" , "spec" , create_specs )
92
+ alt = q .query_float ("What is the alt for the preburn? " )
93
+ preburn = Stage ({})
94
+ engines = []
95
+ engine_rows = VehicleFactory .load_engine_data (spec_data ["engines" ])
96
+ for engine_row in engine_rows :
97
+ engine = RocketEngine .factory (engine_row )
98
+ engine .set_fuel_source (preburn )
99
+ engines .append (engine )
100
+ start_time = q .query_float (
101
+ "What is the {}'s start time (positive start times will be ignored for preburn)? " .format (
102
+ engine .name
103
+ )
104
+ )
105
+ if start_time < 0 :
106
+ start_throt = q .query_min_max (
107
+ "What is the starting throttle for {}" .format (engine .name )
108
+ )
109
+ target_throt = q .query_min_max (
110
+ "What is the target throttle for {}" .format (engine .name )
111
+ )
112
+ # set each weight twice to set average weight
113
+ engine .setThrottleOverride (start_throt )
114
+ if engine .type == "Solid" :
115
+ start_thrust = q .query_min_max (
116
+ "What is the starting "
117
+ + Fore .RED
118
+ + "thrust for {}" .format (engine .name )
119
+ + Style .RESET_ALL ,
120
+ 0 ,
121
+ float ("inf" ),
122
+ )
123
+ start_thrust = q .query_min_max (
124
+ "What is the target "
125
+ + Fore .RED
126
+ + "thrust for {}" .format (engine .name )
127
+ + Style .RESET_ALL ,
128
+ 0 ,
129
+ float ("inf" ),
130
+ )
131
+ engine .set_assigned_thrust_per_engine (start_thrust )
132
+
133
+ time_inc = 0.01
134
+ for i in np .arange (0 , abs (start_time ), time_inc ):
135
+ for engine in engines :
136
+ engine .burn_fuel (time_inc , alt )
137
+ engine .setThrottle (target_throt , time_inc )
138
+
139
+ total_burned = 0.0
140
+ print (preburn .fuel_used )
141
+ # select config file or select engines
142
+ # ask for engine start times
143
+ # for each engine preburn until time 0
144
+ # report amount burned per engine group
145
+ # report total burned
0 commit comments