kiam-astro 2.0.4__py3-none-any.whl → 3.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- kiam_astro/FKIAMToolbox.cp39-win_amd64.pyd +0 -0
- kiam_astro/FKIAMToolbox.cpython-39-darwin.so +0 -0
- kiam_astro/FKIAMToolbox.cpython-39-x86_64-linux-gnu.so +0 -0
- kiam_astro/__pycache__/engine.cpython-39.pyc +0 -0
- kiam_astro/__pycache__/kiam.cpython-39.pyc +0 -0
- kiam_astro/__pycache__/trajectory.cpython-39.pyc +0 -0
- kiam_astro/engine.py +296 -0
- kiam_astro/kiam.py +360 -16
- kiam_astro/trajectory.py +596 -252
- {kiam_astro-2.0.4.dist-info → kiam_astro-3.0.0.dist-info}/METADATA +1 -1
- kiam_astro-3.0.0.dist-info/RECORD +26 -0
- kiam_astro-2.0.4.dist-info/RECORD +0 -24
- {kiam_astro-2.0.4.dist-info → kiam_astro-3.0.0.dist-info}/LICENSE +0 -0
- {kiam_astro-2.0.4.dist-info → kiam_astro-3.0.0.dist-info}/WHEEL +0 -0
- {kiam_astro-2.0.4.dist-info → kiam_astro-3.0.0.dist-info}/top_level.txt +0 -0
kiam_astro/kiam.py
CHANGED
|
@@ -28,7 +28,7 @@ import numpy
|
|
|
28
28
|
import plotly
|
|
29
29
|
import plotly.graph_objects as go
|
|
30
30
|
import pickle
|
|
31
|
-
from typing import Union, Any
|
|
31
|
+
from typing import Union, Any, Callable
|
|
32
32
|
from PIL import Image
|
|
33
33
|
|
|
34
34
|
|
|
@@ -2911,6 +2911,10 @@ def rot2ine_eph(xrot: numpy.ndarray, jd: Union[float, numpy.ndarray], first_body
|
|
|
2911
2911
|
xine = kiam.ine2rot_eph(xrot, jd, 'earth', 'moon', ku['DistUnit'], ku['VelUnit'])
|
|
2912
2912
|
```
|
|
2913
2913
|
"""
|
|
2914
|
+
first_body = first_body.capitalize()
|
|
2915
|
+
secondary_body = secondary_body.capitalize()
|
|
2916
|
+
if first_body == secondary_body:
|
|
2917
|
+
raise 'Bodies should be different.'
|
|
2914
2918
|
initial_xrot_shape = xrot.shape
|
|
2915
2919
|
if len(initial_xrot_shape) == 1:
|
|
2916
2920
|
xrot = numpy.reshape(xrot, (xrot.shape[0], 1))
|
|
@@ -3036,11 +3040,91 @@ def lvlh2mer(xlvlh: numpy.ndarray, lat: float, lon: float) -> numpy.ndarray:
|
|
|
3036
3040
|
FKIAMToolbox.transformations.xlvlh_mat = xlvlh
|
|
3037
3041
|
FKIAMToolbox.transformations.klvlh2mer_mat(lat, lon)
|
|
3038
3042
|
return FKIAMToolbox.transformations.xmer_mat
|
|
3043
|
+
def b1crs2b2crs(body1: str, body2: str, xb1crs: numpy.ndarray, jd: Union[float, numpy.ndarray], dist_unit: float, vel_unit: float) -> numpy.ndarray:
|
|
3044
|
+
"""
|
|
3045
|
+
Translate phase vectors from one CRS c/s to other CRS c/s.
|
|
3046
|
+
|
|
3047
|
+
Parameters:
|
|
3048
|
+
-----------
|
|
3049
|
+
`body1` : str
|
|
3050
|
+
|
|
3051
|
+
The name of the first body.
|
|
3052
|
+
|
|
3053
|
+
`body2` : str
|
|
3054
|
+
|
|
3055
|
+
The name of the second (target) body.
|
|
3056
|
+
|
|
3057
|
+
`xb1crs` : numpy.ndarray, shape (6,), (6,n)
|
|
3058
|
+
|
|
3059
|
+
6D vector or array of 6D column phase vectors in the CRS coordinate system of body1.
|
|
3060
|
+
|
|
3061
|
+
Vector structure: [x, y, z, vx, vy, vz]
|
|
3062
|
+
|
|
3063
|
+
`jd` : float, numpy.ndarray, shape (n,)
|
|
3064
|
+
|
|
3065
|
+
Julian dates corresponding to columns in xb1crs
|
|
3066
|
+
|
|
3067
|
+
`dist_unit` : float
|
|
3068
|
+
|
|
3069
|
+
The unit of distance in km
|
|
3070
|
+
|
|
3071
|
+
`vel_unit` : float
|
|
3072
|
+
|
|
3073
|
+
The unit of velocity in km/s
|
|
3074
|
+
|
|
3075
|
+
Returns:
|
|
3076
|
+
--------
|
|
3077
|
+
`xb2crs` : numpy.ndarray, shape (6,), (6,n)
|
|
3078
|
+
|
|
3079
|
+
6D vector or array of 6D column phase vectors in the CRS coordinate system of body2.
|
|
3080
|
+
|
|
3081
|
+
Vector structure: [x, y, z, vx, vy, vz].
|
|
3082
|
+
|
|
3083
|
+
Examples:
|
|
3084
|
+
---------
|
|
3085
|
+
```
|
|
3086
|
+
Example 1 (6D -> 6D):
|
|
3087
|
+
|
|
3088
|
+
ku = kiam.units('sun', 'mars')
|
|
3089
|
+
|
|
3090
|
+
xb1crs = numpy.array([1, 0, 0, 0, 1, 0]) # wrt the Sun
|
|
3091
|
+
|
|
3092
|
+
jd = kiam.juliandate(2022, 12, 6, 0, 0, 0)
|
|
3093
|
+
|
|
3094
|
+
xb2crs = kiam.b1crs2b2crs('sun', 'mars', xb1crs, jd, ku['DistUnit'], ku['VelUnit']) # wrt Mars
|
|
3095
|
+
|
|
3096
|
+
Example 2 (6x1 -> 6x1)
|
|
3097
|
+
|
|
3098
|
+
ku = kiam.units('sun', 'mars')
|
|
3099
|
+
|
|
3100
|
+
xb1crs = numpy.array([[1, 0, 0, 0, 1, 0]]).T # wrt the Sun
|
|
3101
|
+
|
|
3102
|
+
jd = kiam.juliandate(2022, 12, 6, 0, 0, 0)
|
|
3103
|
+
|
|
3104
|
+
xb2crs = kiam.b1crs2b2crs('sun', 'mars', xb1crs, jd, ku['DistUnit'], ku['VelUnit']) # wrt Mars
|
|
3105
|
+
```
|
|
3106
|
+
"""
|
|
3107
|
+
initial_xb1crs_shape = xb1crs.shape
|
|
3108
|
+
if len(initial_xb1crs_shape) == 1:
|
|
3109
|
+
xb1crs = numpy.reshape(xb1crs, (xb1crs.shape[0], 1))
|
|
3110
|
+
if type(jd) == float or jd.shape == ():
|
|
3111
|
+
jd = numpy.reshape(jd, (1,))
|
|
3112
|
+
dim = xb1crs.shape[0]
|
|
3113
|
+
if dim != 6:
|
|
3114
|
+
raise 'xb1crs should be a 6D vector or 6xn array of vectors.'
|
|
3115
|
+
if xb1crs.shape[1] != jd.shape[0]:
|
|
3116
|
+
raise 'number of columns in xb1crs should equal number of elements in jd.'
|
|
3117
|
+
with _package_folder_contex():
|
|
3118
|
+
xb2crs = FKIAMToolbox.transformations.kb1crs2b2crs(body1.capitalize(), body2.capitalize(), xb1crs, jd, dist_unit, vel_unit)
|
|
3119
|
+
if len(initial_xb1crs_shape) == 1:
|
|
3120
|
+
return xb2crs[:, 0]
|
|
3121
|
+
else:
|
|
3122
|
+
return xb2crs
|
|
3039
3123
|
|
|
3040
3124
|
# Units and constants (documented with examples)
|
|
3041
3125
|
def units(*args: str) -> dict:
|
|
3042
3126
|
"""
|
|
3043
|
-
Get units of distance, velocity, and
|
|
3127
|
+
Get units of distance, velocity, time, and gravitational parameters.
|
|
3044
3128
|
|
|
3045
3129
|
Parameters:
|
|
3046
3130
|
-----------
|
|
@@ -3059,11 +3143,35 @@ def units(*args: str) -> dict:
|
|
|
3059
3143
|
|
|
3060
3144
|
A dictionary containing the units of distance, velocity, and time.
|
|
3061
3145
|
|
|
3062
|
-
DistUnit -- the unit of distance, km
|
|
3146
|
+
`'DistUnit'` -- the unit of distance, km
|
|
3147
|
+
|
|
3148
|
+
`'VelUnit'` -- the unit of velocity, km/s
|
|
3149
|
+
|
|
3150
|
+
`'TimeUnit'` -- the unit of time, days
|
|
3151
|
+
|
|
3152
|
+
`'AccUnit'` -- the unit of acceleration, m/s^2
|
|
3153
|
+
|
|
3154
|
+
`'SunGM'` -- the nondimensional gravitational parameter of the Sun
|
|
3155
|
+
|
|
3156
|
+
`'MercuryGM'` -- the nondimensional gravitational parameter of Mercury
|
|
3157
|
+
|
|
3158
|
+
`'VenusGM'` -- the nondimensional gravitational parameter of Venus
|
|
3063
3159
|
|
|
3064
|
-
|
|
3160
|
+
`'EarthGM'` -- the nondimensional gravitational parameter of the Earth
|
|
3065
3161
|
|
|
3066
|
-
|
|
3162
|
+
`'MoonGM'` -- the nondimensional gravitational parameter of the Moon
|
|
3163
|
+
|
|
3164
|
+
`'EarthMoonGM'` -- the nondimensional gravitational parameter of the Earth+Moon system
|
|
3165
|
+
|
|
3166
|
+
`'MarsGM'` -- the nondimensional gravitational parameter of Mars
|
|
3167
|
+
|
|
3168
|
+
`'JupiterGM'` -- the nondimensional gravitational parameter of Jupiter
|
|
3169
|
+
|
|
3170
|
+
`'SaturnGM'` -- the nondimensional gravitational parameter of Saturn
|
|
3171
|
+
|
|
3172
|
+
`'UranusGM'` -- the nondimensional gravitational parameter of Uranus
|
|
3173
|
+
|
|
3174
|
+
`'NeptuneGM'` -- the nondimensional gravitational parameter of Neptune
|
|
3067
3175
|
|
|
3068
3176
|
Examples:
|
|
3069
3177
|
---------
|
|
@@ -3095,6 +3203,17 @@ def units(*args: str) -> dict:
|
|
|
3095
3203
|
units_info['AccUnit'] = output[5]
|
|
3096
3204
|
else:
|
|
3097
3205
|
raise Exception('Wrong number of arguments in units.')
|
|
3206
|
+
units_info['SunGM'] = FKIAMToolbox.constantsandunits.sun_gm / units_info['GM']
|
|
3207
|
+
units_info['MercuryGM'] = FKIAMToolbox.constantsandunits.mercury_gm / units_info['GM']
|
|
3208
|
+
units_info['VenusGM'] = FKIAMToolbox.constantsandunits.venus_gm / units_info['GM']
|
|
3209
|
+
units_info['EarthGM'] = FKIAMToolbox.constantsandunits.earth_gm / units_info['GM']
|
|
3210
|
+
units_info['MoonGM'] = FKIAMToolbox.constantsandunits.moon_gm / units_info['GM']
|
|
3211
|
+
units_info['EarthMoonGM'] = units_info['EarthGM'] + units_info['MoonGM']
|
|
3212
|
+
units_info['MarsGM'] = FKIAMToolbox.constantsandunits.mars_gm / units_info['GM']
|
|
3213
|
+
units_info['JupiterGM'] = FKIAMToolbox.constantsandunits.jupiter_gm / units_info['GM']
|
|
3214
|
+
units_info['SaturnGM'] = FKIAMToolbox.constantsandunits.saturn_gm / units_info['GM']
|
|
3215
|
+
units_info['UranusGM'] = FKIAMToolbox.constantsandunits.uranus_gm / units_info['GM']
|
|
3216
|
+
units_info['NeptuneGM'] = FKIAMToolbox.constantsandunits.neptune_gm / units_info['GM']
|
|
3098
3217
|
return units_info
|
|
3099
3218
|
def astro_const() -> tuple[dict, dict, dict, dict, dict]:
|
|
3100
3219
|
"""
|
|
@@ -4056,6 +4175,156 @@ def nbp_ee_moon(t: float, s: numpy.ndarray, stm_req: bool, sources: dict, data:
|
|
|
4056
4175
|
_set_nbp_parameters(stm_req, sources, data, units_data)
|
|
4057
4176
|
with _package_folder_contex():
|
|
4058
4177
|
return FKIAMToolbox.equationsmodule.knbp_ee_moon(t, s)
|
|
4178
|
+
def nbp_rv_body(body: str, t: float, s: numpy.ndarray, stm_req: bool, sources: dict, data: dict, units_data: dict) -> numpy.ndarray:
|
|
4179
|
+
"""
|
|
4180
|
+
Right-hand side of the n-body problem equations of motion wrt the specified body (except Earth and Moon) in terms of
|
|
4181
|
+
the position and velocity variables.
|
|
4182
|
+
|
|
4183
|
+
Parameters:
|
|
4184
|
+
-----------
|
|
4185
|
+
`body` : str
|
|
4186
|
+
|
|
4187
|
+
The body wrt that the right-hand side of the equations of motion is calculated.
|
|
4188
|
+
|
|
4189
|
+
Options: `Sun`, `Mercury`, `Venus`, `Mars`, `Jupiter`, `Saturn`, `Uranus`, `Neptune`
|
|
4190
|
+
|
|
4191
|
+
`t` : float
|
|
4192
|
+
|
|
4193
|
+
Time
|
|
4194
|
+
|
|
4195
|
+
`s` : numpy.ndarray, shape (6,), (42,)
|
|
4196
|
+
|
|
4197
|
+
Phase state vector containing position and velocity and (if stm_req = True)
|
|
4198
|
+
vectorized state-transition matrix.
|
|
4199
|
+
|
|
4200
|
+
Vector structure:
|
|
4201
|
+
|
|
4202
|
+
[x, y, z, vx, vy, vz] if stm_req = False
|
|
4203
|
+
|
|
4204
|
+
[x, y, z, vx, vy, vz, m11, m21, m31, ...] if stm_req = True
|
|
4205
|
+
|
|
4206
|
+
`stm_req` : bool
|
|
4207
|
+
|
|
4208
|
+
Flag to calculate the derivative of the state-transition matrix
|
|
4209
|
+
|
|
4210
|
+
`sources` : dict
|
|
4211
|
+
|
|
4212
|
+
Dictionary that contains the perturbations that should be accounted.
|
|
4213
|
+
|
|
4214
|
+
The dictionary keys:
|
|
4215
|
+
|
|
4216
|
+
'srp' (Solar radiation pressure)
|
|
4217
|
+
|
|
4218
|
+
'sun' (Gravitational acceleration of the Sun)
|
|
4219
|
+
|
|
4220
|
+
'mercury' (Gravitational acceleration of Mercury)
|
|
4221
|
+
|
|
4222
|
+
'venus' (Gravitational acceleration of Venus)
|
|
4223
|
+
|
|
4224
|
+
'earth' (Gravitational acceleration of the Earth)
|
|
4225
|
+
|
|
4226
|
+
'mars' (Gravitational acceleration of Mars)
|
|
4227
|
+
|
|
4228
|
+
'jupiter' (Gravitational acceleration of Jupiter)
|
|
4229
|
+
|
|
4230
|
+
'saturn' (Gravitational acceleration of Saturn)
|
|
4231
|
+
|
|
4232
|
+
'uranus' (Gravitational acceleration of Uranus)
|
|
4233
|
+
|
|
4234
|
+
'neptune' (Gravitational acceleration of Neptune)
|
|
4235
|
+
|
|
4236
|
+
If sources[key] = True, the corresponding perturbation will be accounted.
|
|
4237
|
+
|
|
4238
|
+
If sources[key] = False, the corresponding perturbation will not be accounted.
|
|
4239
|
+
|
|
4240
|
+
The sources dictionary with all False values can be created by
|
|
4241
|
+
the kiam.prepare_sources_dict() function.
|
|
4242
|
+
|
|
4243
|
+
`data` : dict
|
|
4244
|
+
|
|
4245
|
+
A dictionary that contains auxilary data.
|
|
4246
|
+
|
|
4247
|
+
The dictionary keys:
|
|
4248
|
+
|
|
4249
|
+
'jd_zero' (Julian date that corresponds to t = 0)
|
|
4250
|
+
|
|
4251
|
+
'order' (Order of the lunar complex gravitational field)
|
|
4252
|
+
|
|
4253
|
+
'area' (Area of the spacecraft to account in atmospheric drag and SRP, m^2)
|
|
4254
|
+
|
|
4255
|
+
'mass' (Mass of the spacecraft to account in atmospheric drag and SRP, kg)
|
|
4256
|
+
|
|
4257
|
+
The data should be submitted even if the corresponding perturbations
|
|
4258
|
+
are not accounted.
|
|
4259
|
+
|
|
4260
|
+
`units_data` : dict
|
|
4261
|
+
|
|
4262
|
+
A dictionary that contains the units.
|
|
4263
|
+
|
|
4264
|
+
The dictionary keys:
|
|
4265
|
+
|
|
4266
|
+
'DistUnit' (The unit of distance in km)
|
|
4267
|
+
|
|
4268
|
+
'VelUnit' (The unit of velocity in km/s)
|
|
4269
|
+
|
|
4270
|
+
'TimeUnit' (The unit of time in days)
|
|
4271
|
+
|
|
4272
|
+
'AccUnit' (The unit of acceleration in m/s^2)
|
|
4273
|
+
|
|
4274
|
+
'RSun' (The radius of the Sun in the units of distance)
|
|
4275
|
+
|
|
4276
|
+
'REarth' (The radius of the Earth in the units of distance)
|
|
4277
|
+
|
|
4278
|
+
'RMoon' (The radius of the Moon in the units of distance)
|
|
4279
|
+
|
|
4280
|
+
The units dictionary can be created by the kiam.prepare_units_dict() function.
|
|
4281
|
+
|
|
4282
|
+
The gravitational parameter in the specified units should be 1.0.
|
|
4283
|
+
|
|
4284
|
+
Returns:
|
|
4285
|
+
--------
|
|
4286
|
+
`f` : numpy.ndarray, shape (6,), (42,)
|
|
4287
|
+
|
|
4288
|
+
Gravitational acceleration according to the specified n-body problem equations
|
|
4289
|
+
of motion extended (if stm_req = True) by the derivative of the
|
|
4290
|
+
state-transition matrix.
|
|
4291
|
+
|
|
4292
|
+
Vector structure:
|
|
4293
|
+
|
|
4294
|
+
[fx, fy, fz, fvx, fvy, fvz] if stm_req = False
|
|
4295
|
+
|
|
4296
|
+
[fx, fy, fz, fvx, fvy, fvz, fm11, fm21, fm31, ... ] if stm_req = True
|
|
4297
|
+
|
|
4298
|
+
Examples:
|
|
4299
|
+
---------
|
|
4300
|
+
```
|
|
4301
|
+
t = 0.0
|
|
4302
|
+
|
|
4303
|
+
s = numpy.array([1, 0, 0, 0, 1, 0])
|
|
4304
|
+
|
|
4305
|
+
stm_req = False
|
|
4306
|
+
|
|
4307
|
+
sources = kiam.prepare_sources_dict()
|
|
4308
|
+
|
|
4309
|
+
data = kiam.prepare_data_dict()
|
|
4310
|
+
|
|
4311
|
+
data['jd_zero'] = kiam.juliandate(2022, 11, 1, 0, 0, 0)
|
|
4312
|
+
|
|
4313
|
+
data['area'] = 1.0
|
|
4314
|
+
|
|
4315
|
+
data['mass'] = 100.0
|
|
4316
|
+
|
|
4317
|
+
units_data = kiam.prepare_units_dict('moon')
|
|
4318
|
+
|
|
4319
|
+
dsdt = kiam.nbp_rv_moon(t, s, stm_req, sources, data, units_data)
|
|
4320
|
+
|
|
4321
|
+
[ 0. 1. 0. -1. -0. -0.]
|
|
4322
|
+
```
|
|
4323
|
+
|
|
4324
|
+
"""
|
|
4325
|
+
_set_nbp_parameters(stm_req, sources, data, units_data)
|
|
4326
|
+
with _package_folder_contex():
|
|
4327
|
+
return FKIAMToolbox.equationsmodule.knbp_rv_body(t, s)
|
|
4059
4328
|
def prepare_sources_dict() -> dict:
|
|
4060
4329
|
"""
|
|
4061
4330
|
Auxilary function that returns a dictionary of perturbations.
|
|
@@ -4204,7 +4473,7 @@ def prepare_units_dict(units_name: str) -> dict:
|
|
|
4204
4473
|
if units_name == 'dim':
|
|
4205
4474
|
return units_data
|
|
4206
4475
|
|
|
4207
|
-
if units_name in ['earth', 'moon']:
|
|
4476
|
+
if units_name in ['sun', 'mercury', 'venus', 'earth', 'moon', 'mars', 'jupiter', 'saturn', 'uranus', 'neptune']:
|
|
4208
4477
|
ku = units(units_name)
|
|
4209
4478
|
units_data['DistUnit'] = ku['DistUnit']
|
|
4210
4479
|
units_data['VelUnit'] = ku['VelUnit']
|
|
@@ -4213,12 +4482,22 @@ def prepare_units_dict(units_name: str) -> dict:
|
|
|
4213
4482
|
units_data['RSun'] = RSun_km / ku['DistUnit']
|
|
4214
4483
|
units_data['REarth'] = REarth_km / ku['DistUnit']
|
|
4215
4484
|
units_data['RMoon'] = RMoon_km / ku['DistUnit']
|
|
4485
|
+
units_data['SunGM'] = ku['SunGM']
|
|
4486
|
+
units_data['MercuryGM'] = ku['MercuryGM']
|
|
4487
|
+
units_data['VenusGM'] = ku['VenusGM']
|
|
4488
|
+
units_data['EarthGM'] = ku['EarthGM']
|
|
4489
|
+
units_data['MoonGM'] = ku['MoonGM']
|
|
4490
|
+
units_data['MarsGM'] = ku['MarsGM']
|
|
4491
|
+
units_data['JupiterGM'] = ku['JupiterGM']
|
|
4492
|
+
units_data['SaturnGM'] = ku['SaturnGM']
|
|
4493
|
+
units_data['UranusGM'] = ku['UranusGM']
|
|
4494
|
+
units_data['NeptuneGM'] = ku['NeptuneGM']
|
|
4216
4495
|
return units_data
|
|
4217
4496
|
|
|
4218
4497
|
raise 'Unknown units_name.'
|
|
4219
4498
|
|
|
4220
4499
|
# Propagation routines (documented with examples)
|
|
4221
|
-
def propagate_nbp(central_body: str, tspan: numpy.ndarray, x0: numpy.ndarray, sources_dict: dict, dat_dict: dict, stm: bool, variables: str) -> tuple[numpy.ndarray, numpy.ndarray]:
|
|
4500
|
+
def propagate_nbp(central_body: str, tspan: numpy.ndarray, x0: numpy.ndarray, sources_dict: dict, dat_dict: dict, units_dict: dict, stm: bool, variables: str, control_function: Callable = None) -> tuple[numpy.ndarray, numpy.ndarray]:
|
|
4222
4501
|
"""
|
|
4223
4502
|
Propagate trajectory in the n-body model of motion.
|
|
4224
4503
|
|
|
@@ -4322,7 +4601,7 @@ def propagate_nbp(central_body: str, tspan: numpy.ndarray, x0: numpy.ndarray, so
|
|
|
4322
4601
|
The sources dictionary with all False values can be created by
|
|
4323
4602
|
the kiam.prepare_sources_dict() function.
|
|
4324
4603
|
|
|
4325
|
-
`dat_dict
|
|
4604
|
+
`dat_dict` : dict
|
|
4326
4605
|
|
|
4327
4606
|
A dictionary that contains auxilary data.
|
|
4328
4607
|
|
|
@@ -4339,6 +4618,12 @@ def propagate_nbp(central_body: str, tspan: numpy.ndarray, x0: numpy.ndarray, so
|
|
|
4339
4618
|
The data should be submitted even if the corresponding perturbations
|
|
4340
4619
|
are not accounted.
|
|
4341
4620
|
|
|
4621
|
+
'units_dict' : dict
|
|
4622
|
+
|
|
4623
|
+
A dictionary that contains the units of distance, velocity, time, acceleration, and the gravitational parameters of the bodies.
|
|
4624
|
+
|
|
4625
|
+
This variable can be generated by kiam.prepare_units_dict function.
|
|
4626
|
+
|
|
4342
4627
|
`stm`: bool
|
|
4343
4628
|
|
|
4344
4629
|
Flag to calculate the derivative of the state-transition matrix
|
|
@@ -4351,6 +4636,16 @@ def propagate_nbp(central_body: str, tspan: numpy.ndarray, x0: numpy.ndarray, so
|
|
|
4351
4636
|
|
|
4352
4637
|
If stm = True, then variables should be 'rv_stm' or 'ee_stm'.
|
|
4353
4638
|
|
|
4639
|
+
`control_function` : Callable
|
|
4640
|
+
|
|
4641
|
+
The control function that returns force vector, specific impulse and (if stm is True) force vector time derivative,
|
|
4642
|
+
|
|
4643
|
+
force vector state derivative, specific impulce time derivative, specific impulse state derivative. The control function
|
|
4644
|
+
|
|
4645
|
+
should take two arguments: the time and the phase state that corresponds to `variables`.
|
|
4646
|
+
|
|
4647
|
+
None by default.
|
|
4648
|
+
|
|
4354
4649
|
Returns:
|
|
4355
4650
|
--------
|
|
4356
4651
|
`t` : numpy.ndarray, shape(n,)
|
|
@@ -4411,25 +4706,60 @@ def propagate_nbp(central_body: str, tspan: numpy.ndarray, x0: numpy.ndarray, so
|
|
|
4411
4706
|
|
|
4412
4707
|
dat_dict = kiam.prepare_data_dict()
|
|
4413
4708
|
|
|
4709
|
+
units_dict = kiam.prepare_units_dict('earth')
|
|
4710
|
+
|
|
4414
4711
|
stm = False
|
|
4415
4712
|
|
|
4416
4713
|
variables = 'rv'
|
|
4417
4714
|
|
|
4418
|
-
t, y = kiam.propagate_nbp(central_body, tspan, x0, sources_dict, dat_dict, stm, variables)
|
|
4715
|
+
t, y = kiam.propagate_nbp(central_body, tspan, x0, sources_dict, dat_dict, units_dict, stm, variables)
|
|
4419
4716
|
```
|
|
4420
4717
|
"""
|
|
4421
4718
|
tspan, x0 = to_float(tspan, x0)
|
|
4422
|
-
neq =
|
|
4719
|
+
neq = x0.shape[0]
|
|
4423
4720
|
if variables == 'rv_stm':
|
|
4424
4721
|
variables = 'rv'
|
|
4425
4722
|
elif variables == 'ee_stm':
|
|
4426
4723
|
variables = 'ee'
|
|
4427
|
-
|
|
4428
|
-
|
|
4429
|
-
|
|
4430
|
-
|
|
4431
|
-
|
|
4432
|
-
|
|
4724
|
+
_set_nbp_parameters(stm, sources_dict, dat_dict, units_dict)
|
|
4725
|
+
|
|
4726
|
+
if control_function is None:
|
|
4727
|
+
|
|
4728
|
+
if variables == 'rvm':
|
|
4729
|
+
|
|
4730
|
+
raise Exception('If not control_function is specified, use rv variables instead of rvm.')
|
|
4731
|
+
|
|
4732
|
+
with _package_folder_contex():
|
|
4733
|
+
T, Y = FKIAMToolbox.propagationmodule.propagate_nbp(central_body.capitalize(), tspan, x0, variables, neq)
|
|
4734
|
+
|
|
4735
|
+
else:
|
|
4736
|
+
|
|
4737
|
+
if variables != 'rvm':
|
|
4738
|
+
|
|
4739
|
+
raise Exception('Propagation with control_function is implemented only for rvm variables.')
|
|
4740
|
+
|
|
4741
|
+
if not stm:
|
|
4742
|
+
|
|
4743
|
+
def control(t, x): # может быть сделать external на уровне module, а не function?
|
|
4744
|
+
force_vector, specific_impulse = control_function(t, x) # control_function(t, x)
|
|
4745
|
+
FKIAMToolbox.equationsmodule.force_vector = force_vector
|
|
4746
|
+
FKIAMToolbox.equationsmodule.specific_impulse = specific_impulse
|
|
4747
|
+
|
|
4748
|
+
else:
|
|
4749
|
+
|
|
4750
|
+
def control(t, x): # может быть сделать external на уровне module, а не function?
|
|
4751
|
+
force_vector, specific_impulse, dFdt, dFdx, dIdt, dIdx = control_function(t, x) # control_function(t, x)
|
|
4752
|
+
FKIAMToolbox.equationsmodule.force_vector = force_vector
|
|
4753
|
+
FKIAMToolbox.equationsmodule.specific_impulse = specific_impulse
|
|
4754
|
+
FKIAMToolbox.equationsmodule.force_vector_time_derivative = dFdt
|
|
4755
|
+
FKIAMToolbox.equationsmodule.force_vector_state_derivative = dFdx
|
|
4756
|
+
FKIAMToolbox.equationsmodule.specific_impulse_time_derivative = dIdt
|
|
4757
|
+
FKIAMToolbox.equationsmodule.specific_impulse_state_derivative = dIdx
|
|
4758
|
+
|
|
4759
|
+
with _package_folder_contex():
|
|
4760
|
+
T, Y = FKIAMToolbox.propagationmodule.propagate_nbp_control(central_body.capitalize(), tspan, x0, variables, neq, control)
|
|
4761
|
+
|
|
4762
|
+
return T, Y
|
|
4433
4763
|
def propagate_r2bp(tspan: numpy.ndarray, x0: numpy.ndarray) -> tuple[numpy.ndarray, numpy.ndarray]:
|
|
4434
4764
|
"""
|
|
4435
4765
|
Propagate trajectory in the two-body model of motion.
|
|
@@ -5178,6 +5508,20 @@ def _set_nbp_parameters(stm_req: bool, sources: dict, data: dict, units_data: di
|
|
|
5178
5508
|
FKIAMToolbox.equationsmodule.rsun = units_data['RSun']
|
|
5179
5509
|
FKIAMToolbox.equationsmodule.rearth = units_data['REarth']
|
|
5180
5510
|
FKIAMToolbox.equationsmodule.rmoon = units_data['RMoon']
|
|
5511
|
+
|
|
5512
|
+
FKIAMToolbox.equationsmodule.musun = units_data['SunGM']
|
|
5513
|
+
FKIAMToolbox.equationsmodule.mumercury = units_data['MercuryGM']
|
|
5514
|
+
FKIAMToolbox.equationsmodule.muvenus = units_data['VenusGM']
|
|
5515
|
+
FKIAMToolbox.equationsmodule.muearth = units_data['EarthGM']
|
|
5516
|
+
FKIAMToolbox.equationsmodule.momoon = units_data['MoonGM']
|
|
5517
|
+
FKIAMToolbox.equationsmodule.mumars = units_data['MarsGM']
|
|
5518
|
+
FKIAMToolbox.equationsmodule.mujupiter = units_data['JupiterGM']
|
|
5519
|
+
FKIAMToolbox.equationsmodule.musaturn = units_data['SaturnGM']
|
|
5520
|
+
FKIAMToolbox.equationsmodule.muuranus = units_data['UranusGM']
|
|
5521
|
+
FKIAMToolbox.equationsmodule.muneptune = units_data['NeptuneGM']
|
|
5522
|
+
|
|
5523
|
+
FKIAMToolbox.equationsmodule.g0 = 9.80665 / units_data['AccUnit']
|
|
5524
|
+
|
|
5181
5525
|
def _return_if_grad_req(out: tuple[numpy.ndarray, numpy.ndarray], grad_req: bool) -> Union[tuple[numpy.ndarray, numpy.ndarray], numpy.ndarray]:
|
|
5182
5526
|
"""
|
|
5183
5527
|
FOR THE TOOLBOX DEVELOPERS ONLY.
|