Skip to content

Commit 250c65f

Browse files
ROC v2.0: Improved computational efficiency under uncertainty
1 parent 526955a commit 250c65f

File tree

12 files changed

+880
-138
lines changed

12 files changed

+880
-138
lines changed

.DS_Store

0 Bytes
Binary file not shown.

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ The Python Library roc is a software package developed by UC3M. It is a tool for
1212

1313
**Support:** Support of all general technical questions on roc, i.e., installation, application, and development, will be provided by Abolfazl Simorgh (abolfazl.simorgh@uc3m.es).
1414

15-
**Core developer team:** Daniel González Arribas, Abolfazl Simorgh, and Manuel Soler.
16-
1715
Copyright (C) 2022, Universidad Carlos III de Madrid
1816

1917
## Citation info
@@ -33,7 +31,7 @@ conda create -n env_roc python=3.9
3331
conda activate env_roc
3432
```
3533

36-
1. Clone or download the repository. The roost source code is available on a public GitHub repository: https://github.com/Abolfazl-Simorgh/roc. The easiest way to obtain it is to clone the repository using git: git clone https://github.com/Abolfazl-Simorgh/roc.git.
34+
1. Clone or download the repository. The roost source code is available on a public GitHub repository: https://github.com/Aircraft-Operations-Lab/roc. The easiest way to obtain it is to clone the repository using git: git clone https://github.com/Aircraft-Operations-Lab/roc.git.
3735

3836
2. Locate yourself in the roost (library folder) path, and run the following line, using terminal (MacOS and Linux) or cmd (Windows), which will install all dependencies:
3937
```python

roc3/accf.py

Lines changed: 71 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,80 @@ def aCCF_dCont(olr):
2929

3030

3131
def aCCF_nCont(t):
32-
accf_nCont = 13.9 * 0.0151 * (1e-10 * (0.0073 * 10 ** (0.0107 * t) - 1.03)) * 0.42/ 3
32+
accf_nCont = 13.9 * 0.0151 * (1e-10 * (0.0073 * np.power(10, 0.0107 * t) - 1.03)) * 0.42/ 3
3333
return accf_nCont
3434

3535

36+
def G (P):
37+
G_ = (1.23 * 1004 * P)/(0.6222 * 43130000 * 0.7)
38+
return G_
39+
40+
def T_crit (G):
41+
T_c = -46.46 + 9.43 * np.log(G - 0.053) + 0.72 * np.power(np.log(G - 0.053),2) + 273.15
42+
return T_c
43+
44+
def rlw (q, P, el_t_amb):
45+
r_h = (q * P * (461.51/287.05)) / el_t_amb
46+
return r_h
47+
48+
def rh(q, T, p):
49+
R_d = 287.05
50+
R_v = 461.51
51+
rh = (q * p * (R_v / R_d)) / e_sat_liquid(T)
52+
return rh
53+
54+
def e_sat_liquid (t):
55+
eL_T = 100 * np.exp(-6096.9385/t + 16.635794 - 0.02711193 * t + 1.673952 * 1e-5 * np.power(t, 2) + 2.433502 * np.log(t))
56+
return eL_T
57+
58+
59+
60+
def rhi(q, T, p):
61+
R_d = 287.05
62+
R_v = 461.51
63+
return (q * p * (R_v /R_d)) / e_sat_ice(T)
64+
65+
66+
67+
def e_sat_ice(t):
68+
return 100 * np.exp( # type: ignore[return-value]
69+
(-6024.5282 / t)
70+
+ 24.7219
71+
+ (0.010613868 * t)
72+
- (1.3198825e-5 * (t**2))
73+
- 0.49382577 * np.log(t)
74+
)
75+
76+
def r_cont (G, t, t_c, el_t_c, el_t_amb):
77+
r_sac = (G * (t - t_c) + el_t_c) / el_t_amb
78+
return r_sac
79+
80+
81+
T0_MSL = 288.15
82+
P0_MSL = 101325.0
83+
lapse_rate_troposphere = -0.0065
84+
85+
def Hp2P(Hp):
86+
return P0_MSL*(1 + lapse_rate_troposphere*Hp/T0_MSL)**5.2561
87+
88+
89+
def FL2P (FL):
90+
Hp = FL * 30.48
91+
P = Hp2P(Hp)/100 #hpa
92+
return P
93+
94+
95+
def sigmd (x, c, x_cut):
96+
return 1 / (1 + np.exp( -c * (x-x_cut) ) )
97+
98+
99+
def sac (r_sac, r_hm, T, T_crit):
100+
T_condition = sigmd (T_crit, 3, T)
101+
R_condition = sigmd (r_hm, 20, r_sac)
102+
sac_ = R_condition * T_condition
103+
return sac_
104+
105+
36106
def pcfa(r, t, r_thr, t_thr, r_pa, t_pa):
37107
t_condition = 1/(1+np.exp(-t_pa*(-t+t_thr)))
38108
r_condition = 1/(1+np.exp(-r_pa*( r-r_thr)))

roc3/initial_guess.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,13 @@ def patch_mass_and_altitude(fpp: FPP, trj, m0, n_nodes=8000):
266266
ig.p['min_atr'] = 0
267267
ig.p['max_atr'] = 0
268268
if fpp.pcfg['airspeed'] != 'constant' and fpp.pcfg['climate_impact'] and fpp.pcfg['climate_modeling'] == 'mayer' and not fpp.pcfg['climate_std']:
269-
ig.x['atr'] = I(s, atr)
269+
ig.x['atr'] = I(s, atr)
270+
ig.p['wp1'] = 593.6373951051227
271+
ig.p['wp2'] = 883.8547170355159
272+
# ig.p['wp3'] = 1100
273+
274+
275+
270276
ig.p['lft'] = t[-1]
271277
ig.p['eft'] = t[-1]
272278
ig.u['tas_slope'] = I(s, tas_slopes)
@@ -498,6 +504,11 @@ def avg_crs(course_1, course_2):
498504
ig.x['tas'] = I(distances, VTas)
499505
ig.x['t_0'] = I(distances, times)
500506
ig.x['m_0'] = I(distances, masses)
507+
ig.p['wp1'] = 593.6373951051227
508+
ig.p['wp2'] = 883.8547170355159
509+
# ig.p['wp3'] = 1100
510+
511+
501512
ig.p['lft'] = times[-1]
502513
ig.p['eft'] = times[-1]
503514
ig.u['tas_slope'] = I(distances, accelerations)

roc3/modified_bada.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# -*- coding: utf-8 -*-
2+
3+
import numpy as np
4+
import casadi
5+
6+
from roc3.bada4 import *
7+
from roc3.apm import *
8+
9+
from casadi import interpolant, vertcat
10+
11+
class Label(object):
12+
def __init__(self, path):
13+
self.arrs = np.load(path)
14+
self.CL_coords = self.arrs['CL'][0,:]
15+
self.M_coords = self.arrs['MACH'][0,:]
16+
self.D_values = self.arrs['jetCR.D'][0,:]
17+
def get_CD_interpolant(self):
18+
xx = [self.CL_coords, self.M_coords]
19+
y = self.D_values.T.flatten()
20+
I = interpolant('CD', 'bspline', xx, y, {})
21+
return lambda CL, M: I(vertcat(CL, M))
22+
23+
class ModifiedBADA(BADA4_jet_CR):
24+
def __init__(self, label, array_path):
25+
self.isa = ISA()
26+
self.label_tabular = Label(array_path)
27+
super().__init__(label)
28+
self.I_CD = self.label_tabular.get_CD_interpolant()
29+
# def fc_from_thrust_P_M_T(self, thrust, P, M, T):
30+
# Hp = P2Hp(P)
31+
# T_ISA = self.isa.IT(Hp)
32+
# uncorrected_fc = self.I_fc(vertcat(thrust, Hp, M))
33+
# return uncorrected_fc*(T/T_ISA)**.5
34+
def CD_from_CL_M(self, CL, M):
35+
return self.I_CD(CL, M)

roc3/pipelines.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
import numpy as np
44

5-
from roc3.weather import WeatherModel
6-
from roc3.rfp import *
7-
from roc3.initial_guess import *
5+
from .weather import WeatherModel
6+
from .rfp import *
7+
from .initial_guess import *
88

99

1010
class Routing2DStandard(object):
@@ -23,12 +23,14 @@ def __init__(self, apm, weather_model, problem_config, n_nodes, hazards={}, conf
2323
self.wm_det = weather_model.get_slice_with_first_member()
2424
self.pcfg = problem_config
2525
self.n_nodes = n_nodes
26+
2627
self.config = {
2728
'n_ig': 200,
28-
'n_det1': 20,
29-
'n_det2': 40,
30-
'n_robust1': 40,
31-
}
29+
'n_det1': 30,
30+
'n_det2': 60,
31+
'n_robust1': 60,
32+
}
33+
3234
self.config.update(config)
3335
# solver_options ['mu_init'] = 10**-9
3436
self.solver_options = solver_options
@@ -133,6 +135,7 @@ def solve(self, stop=False, estimations={}):
133135
self.check_trj_in_wm_bounds(new_ig, self.wm_det)
134136
fpp_det.build_ocp()
135137
trj = fpp_det.solve(new_ig, n_nodes=self.config['n_det2'], solver_options=self.solver_options)
138+
# trj = fpp_det.solve(new_ig, n_nodes=self.config['n_det2'], solver_options={'max_iter':0})
136139
# fpp_det.autoplot()
137140
self.trjs_steps.append(trj)
138141

@@ -142,14 +145,11 @@ def solve(self, stop=False, estimations={}):
142145

143146
new_ig = trj.get_interpolator(patch_tu=True)
144147
so = self.solver_options.copy()
145-
so['mu_init'] = 10**-3.8
146-
so['max_iter'] = 1500
147-
trj = fpp.solve(new_ig, n_nodes=self.config['n_robust1'], solver_options=so)
148+
so['max_iter'] = 2000
149+
trj = fpp.solve(new_ig, n_nodes=self.config['n_det2'], solver_options=so)
148150
self.trjs_steps.append(trj)
149151

150-
151152
new_ig = trj.get_interpolator(patch_tu=True)
152-
so['mu_init'] = 10**-3.8
153153
trj = fpp.solve(new_ig, n_nodes=self.n_nodes, solver_options=so)
154154
self.trjs_steps.append(trj)
155155

0 commit comments

Comments
 (0)