-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlauncher.js
More file actions
57 lines (43 loc) · 1.94 KB
/
launcher.js
File metadata and controls
57 lines (43 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
const {getInitData, trj2CSV} = require('./modules/fileUtils.js')
//===========================================================
getInitData('./model.json')
.then( modelConfig => {
const {activeVariant, initialVars} = modelConfig
const {vehicle, planet, launchConditions, dT} = initialVars[activeVariant]
const planetDataPath = `./enviro/${planet.toLowerCase()}.json`
const vehicleDataPath = `./data/${vehicle.toLowerCase()}.json`
getInitData(planetDataPath)
.then(({R, K, atmosphere, k_gas, R_gas, solar_constant}) => {
const AtmoModel = require('./modules/atmoModel.js')
const Atmo = new AtmoModel()
Atmo.initAtmo(atmosphere)
global.ENVIRO = {
RE: R,
KE: K,
k_gas,
R_gas,
solar_constant,
Atmo,
vCircular: H => Math.sqrt(K / H)
}
return getInitData(vehicleDataPath)
})
.then(({initData, alpha_controls, fuel_controls, roll_controls, stage_controls}) => {
const CompositeVehicle = require('./modules/compositeVehicle.js')
const {setupControls} = require('./modules/controls.js')
const {local2Global, analyzeTrajectory} = require('./modules/trajectoryUtils.js')
const {V, H, Th, Psi, W, L} = launchConditions
const {Vx, Vy, Vz, X, Y, Z} = local2Global(V, H, Th / 57.3, Psi / 57.3, W / 57.3, L/57.3)
const timeOut = function(dataPoint) {
const {t, kinematics} = dataPoint
const totalH = Math.sqrt(kinematics[3] * kinematics[3] + kinematics[4] * kinematics[4] + kinematics[5] * kinematics[5])
return dataPoint.t > 4500 || totalH < global.ENVIRO.RE
}
const controlFunctions = setupControls(alpha_controls, fuel_controls, roll_controls, stage_controls)
const testVehicle = new CompositeVehicle()
testVehicle.setupVehicle(initData, controlFunctions)
const {trajectory, stageTau} = testVehicle.calcTrajectory(timeOut, [Vx, Vy, Vz, X, Y, Z], dT)
const analyzedTrajectory = analyzeTrajectory(trajectory, testVehicle, stageTau, 10)
trj2CSV(analyzedTrajectory, 'test_trajectory')
})
})