the mission [this is a numdiff_type
for
organizational purposes.... rethink this maybe ...
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
character(len=:), | public, | allocatable | :: | initial_guess_from_file |
to read the initial guess from a JSOn file |
||
logical, | public | :: | use_splined_ephemeris | = | .false. |
if true, the ephemeris is splined |
|
real(kind=wp), | public | :: | dt_spline_sec | = | 3600.0_wp |
time step in seconds for spline step [1 hr] |
|
logical, | public | :: | pointmass_central_body | = | .false. |
if true, the central body is a pointmass (moon).
otherwise, the |
|
type(geopotential_model_pines), | public, | pointer | :: | grav | => | null() |
central body geopotential model [global] |
class(jpl_ephemeris), | public, | pointer | :: | eph | => | null() |
the ephemeris [global] |
type(segment), | public, | dimension(:), allocatable | :: | segs |
the list of segments |
||
real(kind=wp), | public, | dimension(:), allocatable | :: | xscale |
opt var scale factors |
||
real(kind=wp), | public, | dimension(:), allocatable | :: | dpert_ |
opt var dpert factors [rename because already in base class] |
||
real(kind=wp), | public, | dimension(:), allocatable | :: | fscale |
function scale factors |
||
character(len=20), | public, | dimension(:), allocatable | :: | xname |
opt var names |
||
character(len=:), | public, | allocatable | :: | N_or_S |
'N' or 'S' |
||
character(len=:), | public, | allocatable | :: | L1_or_L2 |
'L1' or 'L2' |
||
logical, | public | :: | solve | = | .true. |
run the nle solver to solve the problem |
|
logical, | public | :: | generate_plots | = | .true. |
to generate the python plots |
|
logical, | public | :: | generate_trajectory_files | = | .true. |
to export the txt trajectory files. |
|
logical, | public | :: | generate_json_trajectory_file | = | .false. |
to export the JSON trajectory file for the solution (contains inertial and rotating data). This one is used by the PyVista python script for plotting |
|
logical, | public | :: | generate_guess_and_solution_files | = | .true. |
to export the json guess and solution files. |
|
logical, | public | :: | generate_kernel | = | .false. |
to generate a spice kernel (bsp) of the solution [this requires the external mkspk SPICE tool] |
|
logical, | public | :: | generate_defect_file | = | .false. |
generate the file that shows the pos/vel constraint defects for the solution |
|
logical, | public | :: | generate_eclipse_files | = | .false. |
generate the eclipse data file for the solution |
|
logical, | public | :: | run_pyvista_script | = | .false. |
run the pyvista script to generate the interacdtive 3d plot |
|
real(kind=wp), | public | :: | r_eclipse_bubble | = | 0.0_wp |
radius of the "eclipse bubble" [km] |
|
real(kind=wp), | public | :: | eclipse_dt_step | = | 3600.0_wp |
dense time step output for eclipse calculations in sec [1 hour] |
|
integer, | public | :: | eclipse_filetype | = | 1 |
type of eclipse file: 1=csv or 2=json |
|
integer, | public | :: | epoch_mode | = | 1 |
1 - calendar date was specified, 2 - ephemeris time was specified |
|
integer, | public | :: | year | = | 0 |
epoch of first point (first periapsis crossing) |
|
integer, | public | :: | month | = | 0 |
epoch of first point (first periapsis crossing) |
|
integer, | public | :: | day | = | 0 |
epoch of first point (first periapsis crossing) |
|
integer, | public | :: | hour | = | 0 |
epoch of first point (first periapsis crossing) |
|
integer, | public | :: | minute | = | 0 |
epoch of first point (first periapsis crossing) |
|
real(kind=wp), | public | :: | sec | = | zero |
epoch of first point (first periapsis crossing) |
|
real(kind=wp), | public | :: | et_ref | = | zero |
ephemeris time reference epoch [sec]
(all times relative to this).
this is computed from the year,month,day,hour,minute,sec values
if |
|
integer, | public | :: | n_revs | = | 10 |
Number of revs in the Halo. |
|
real(kind=wp), | public | :: | rtol | = | 1.0e-12_wp |
integrator rtol |
|
real(kind=wp), | public | :: | atol | = | 1.0e-12_wp |
integrator atol |
|
real(kind=wp), | public | :: | nlesolver_tol | = | 1.0e-6_wp |
nlesolver tol |
|
real(kind=wp), | public, | dimension(:), allocatable | :: | initial_r |
if |
||
character(len=:), | public, | allocatable | :: | ephemeris_file |
the JPL ephemeris file to load |
||
character(len=:), | public, | allocatable | :: | gravfile |
spherical harmonic gravity coeff file (Moon) example: 'data/grav/gggrx_0020pm_sha.tab' |
||
character(len=:), | public, | allocatable | :: | patch_point_file |
Halo CR3BP patch point solution file example: 'data/L2_halos.json' |
||
logical, | public | :: | patch_point_file_is_periapsis | = | .false. |
if the state in the patch point file are periapsis states (false means they are apoapsis states. the ones in L2_halos.json are apoapsis states) |
|
type(patch_point), | public | :: | periapsis |
Patchpoint Periapse State |
|||
type(patch_point), | public | :: | quarter |
Patchpoint 1/4 Rev State |
|||
type(patch_point), | public | :: | apoapsis |
Patchpoint 1/2 Rev State |
|||
real(kind=wp), | public | :: | period | = | 0.0_wp |
Halo period [days] |
|
real(kind=wp), | public | :: | period8 | = | 0.0_wp |
1/8 of Halo period [days] |
|
logical, | public | :: | fix_initial_time | = | .false. |
to fix the initial epoch in the mission |
|
logical, | public | :: | fix_initial_r | = | .false. |
fix the initial periapsis position vector (x,y,z) |
|
integer, | public | :: | fix_ry_at_end_of_rev | = | 0 |
fix ry at the end of the specified rev (at periapsis)
not used if |
|
logical, | public | :: | fix_final_ry_and_vx | = | .false. |
fix ry and vx at the end of the last rev (at periapsis) |
|
integer, | public | :: | solver_mode | = | 1 |
use sparse or dense solver:
|
Initialize the mission.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(mission_type), | intent(inout) | :: | me | |||
real(kind=wp), | intent(out), | optional, | dimension(:), allocatable | :: | x |
initial guess |
Plot the trajectory using matplotlib and/or generate a text file (for MKSPK)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(mission_type), | intent(inout) | :: | me | |||
character(len=*), | intent(in) | :: | filename |
plot file name [without extension] |
||
logical, | intent(in), | optional | :: | export_trajectory |
if true, a text trajectory file is also produced (that can be read by MKSPK) [default is False] |
|
logical, | intent(in), | optional | :: | draw_trajectory |
if true [Default], a matplotlib plot is generated |
|
logical, | intent(in), | optional | :: | only_first_rev |
to only do the first rev [Default is False] |
Export the trajectory JSON file.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(mission_type), | intent(inout) | :: | me | |||
character(len=*), | intent(in) | :: | filename |
plot file name [without extension] |
||
logical, | intent(in), | optional | :: | only_first_rev |
to only do the first rev [Default is False] |
Write the current x
variables to a file (compatible with the Copernicus optvar file).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(mission_type), | intent(inout) | :: | me | |||
character(len=*), | intent(in) | :: | filename |
file name [without extension] |
||
real(kind=wp), | intent(in), | dimension(:) | :: | x |
solver opt vars vector |
Computes the constraint violation vector for the mission.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(mission_type), | intent(inout) | :: | me | |||
real(kind=wp), | intent(in), | dimension(:) | :: | x |
opt var vector for the mission [n] |
|
real(kind=wp), | intent(out), | dimension(:) | :: | f |
constraint violation vector for the mission [m] |
|
integer, | intent(in), | optional, | dimension(:) | :: | funcs_to_compute |
the indices of f to compute |
Print the r
and v
constraint defect norms for each segment constraint.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(mission_type), | intent(in) | :: | me | |||
character(len=*), | intent(in) | :: | filename |
csv file to write to |
Propagate all the segments with a dense time step and export the Eclipsing data w.r.t. Earth. In this file, any point <0 is in eclipse.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(mission_type), | intent(inout) | :: | me | |||
character(len=*), | intent(in) | :: | fileprefix |
file prefix for the csv file (case name will be added) |
||
integer, | intent(in), | optional | :: | filetype |
type of output file: 1=csv [default] or 2=json |
Get the arrays for the problem
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(mission_type), | intent(in) | :: | me | |||
real(kind=wp), | intent(out), | optional, | dimension(:) | :: | x |
opt var vector [scaled] |
real(kind=wp), | intent(out), | optional, | dimension(:) | :: | f |
constraint violations |
Take the x
vector from the solver, and use it to populate all the segments
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(mission_type), | intent(inout) | :: | me | |||
real(kind=wp), | intent(in), | dimension(:) | :: | x_scaled |
opt var vector (scaled) |
Read the JSON solution file and put the x
vector in the mission.
Can be used to restart a solution from a previous run
(e.g., with different settings, as long as the fundamental problem isn't changed).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(mission_type), | intent(inout) | :: | me | |||
real(kind=wp), | intent(out), | dimension(:), allocatable | :: | x |
scaled |
Populate the xscale
and fscale
problem arrays from the segment data.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(mission_type), | intent(inout) | :: | me |
Given the functions to be computed, returns the segments that need to be propagated.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(mission_type), | intent(inout) | :: | me | |||
integer, | intent(in), | optional, | dimension(:) | :: | funcs_to_compute |
the indices of f to compute |
integer, | intent(out), | dimension(:), allocatable | :: | isegs_to_propagate |
segment numbers |
Returns the sparsity pattern for the "forward-backward" Halo problem.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(mission_type), | intent(inout) | :: | me | |||
integer, | intent(out), | dimension(:), allocatable | :: | irow |
sparsity pattern nonzero elements row indices |
|
integer, | intent(out), | dimension(:), allocatable | :: | icol |
sparsity pattern nonzero elements column indices |
|
integer, | intent(out), | optional, | dimension(:), allocatable | :: | linear_irow |
linear sparsity pattern nonzero elements row indices |
integer, | intent(out), | optional, | dimension(:), allocatable | :: | linear_icol |
linear sparsity pattern nonzero elements column indices |
real(kind=wp), | intent(out), | optional, | dimension(:), allocatable | :: | linear_vals |
linear sparsity values (constant elements of the Jacobian) |
integer, | intent(out), | optional | :: | maxgrp |
DSM sparsity partition |
|
integer, | intent(out), | optional, | dimension(:), allocatable | :: | ngrp |
DSM sparsity partition |
Returns the size variables for the "forward-backward" formulation of the problem.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(mission_type), | intent(in) | :: | me | |||
integer, | intent(out), | optional | :: | n |
number of opt vars for the solver |
|
integer, | intent(out), | optional | :: | m |
number of equality constraints for the solver |
|
integer, | intent(out), | optional | :: | n_segs |
number of segments |
|
integer, | intent(out), | optional | :: | n_nonzero |
number of nonzero elements in the Jacobian |
|
logical, | intent(in), | optional | :: | full_problem |
if true (default) always return the results for the full problem (i.e., without fixing any of the variables) |
Returns a string that can be used for file names, etc. (read the values of the global variables).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(mission_type), | intent(in) | :: | me |
Generates the patch points (unnormalized, moon-centered) from the CR3BP normalized guess.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(mission_type), | intent(inout) | :: | me | |||
real(kind=wp), | intent(in) | :: | lstar | |||
real(kind=wp), | intent(in) | :: | tstar | |||
real(kind=wp), | intent(in) | :: | period | |||
real(kind=wp), | intent(in) | :: | x0 | |||
real(kind=wp), | intent(in) | :: | z0 | |||
real(kind=wp), | intent(in) | :: | ydot0 | |||
type(patch_point), | intent(out), | dimension(3) | :: | pp |
periapsis, quarter, apoapsis patch points |
Update the variables for the reference epoch in the mission class. Either computes the et from the calendar state, or vice versa.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(mission_type), | intent(inout) | :: | me |
type,extends(numdiff_type) :: mission_type !! the mission [this is a `numdiff_type` for !! organizational purposes.... rethink this maybe ... character(len=:),allocatable :: initial_guess_from_file !! to read the initial guess from a JSOn file logical :: use_splined_ephemeris = .false. !! if true, the ephemeris is splined real(wp) :: dt_spline_sec = 3600.0_wp !! time step in seconds for spline step [1 hr] logical :: pointmass_central_body = .false. !! if true, the central body is a pointmass (moon). !! otherwise, the `grav` model is used. type(geopotential_model_pines),pointer :: grav => null() !! central body geopotential model [global] class(jpl_ephemeris),pointer :: eph => null() !! the ephemeris [global] type(segment),dimension(:),allocatable :: segs !! the list of segments real(wp),dimension(:),allocatable :: xscale !! opt var scale factors real(wp),dimension(:),allocatable :: dpert_ !! opt var dpert factors [rename because already in base class] real(wp),dimension(:),allocatable :: fscale !! function scale factors character(len=20),dimension(:),allocatable :: xname !! opt var names character(len=:),allocatable :: N_or_S !! 'N' or 'S' character(len=:),allocatable :: L1_or_L2 !! 'L1' or 'L2' logical :: solve = .true. !! run the nle solver to solve the problem logical :: generate_plots = .true. !! to generate the python plots logical :: generate_trajectory_files = .true. !! to export the txt trajectory files. logical :: generate_json_trajectory_file = .false. !! to export the JSON trajectory file for the solution !! (contains inertial and rotating data). This one is used !! by the PyVista python script for plotting logical :: generate_guess_and_solution_files = .true. !! to export the json guess and solution files. logical :: generate_kernel = .false. !! to generate a spice kernel (bsp) of the solution !! [this requires the external mkspk SPICE tool] logical :: generate_defect_file = .false. !! generate the file that shows the pos/vel !! constraint defects for the solution logical :: generate_eclipse_files = .false. !! generate the eclipse data file for the solution logical :: run_pyvista_script = .false. !! run the pyvista script to generate the interacdtive 3d plot real(wp) :: r_eclipse_bubble = 0.0_wp !! radius of the "eclipse bubble" [km] real(wp) :: eclipse_dt_step = 3600.0_wp !! dense time step output for eclipse calculations in sec [1 hour] integer :: eclipse_filetype = 1 !! type of eclipse file: 1=csv or 2=json integer :: epoch_mode = 1 !! 1 - calendar date was specified, 2 - ephemeris time was specified integer :: year = 0 !! epoch of first point (first periapsis crossing) integer :: month = 0 !! epoch of first point (first periapsis crossing) integer :: day = 0 !! epoch of first point (first periapsis crossing) integer :: hour = 0 !! epoch of first point (first periapsis crossing) integer :: minute = 0 !! epoch of first point (first periapsis crossing) real(wp) :: sec = zero !! epoch of first point (first periapsis crossing) real(wp) :: et_ref = zero !! ephemeris time reference epoch [sec] !! (all times relative to this). !! this is computed from the year,month,day,hour,minute,sec values !! if `epoch_mode=1` integer :: n_revs = 10 !! Number of revs in the Halo. real(wp) :: rtol = 1.0e-12_wp !! integrator rtol real(wp) :: atol = 1.0e-12_wp !! integrator atol real(wp) :: nlesolver_tol = 1.0e-6_wp !! nlesolver tol real(wp),dimension(:),allocatable :: initial_r !! if `fix_initial_r` is True, this can be used !! to specify the initial `r` (moon-centered earth-moon rotating frame) character(len=:),allocatable :: ephemeris_file !! the JPL ephemeris file to load ! [note: these are build using the get_third_party script in FAT. ! the files are platform (and maybe compiler specific) ! 'data/eph/JPLEPH.421' !! JPL DE421 ephemeris file [mac,gfortran] ! 'data/eph/JPLEPH_intel_mac.421' !! [mac,ifort] ! 'data/eph/JPLEPH_windows_ifort.421' !! [windows,ifort] ! environment and integrator parameters: character(len=:),allocatable :: gravfile !! spherical harmonic gravity coeff file (Moon) !! example: 'data/grav/gggrx_0020pm_sha.tab' character(len=:),allocatable :: patch_point_file !! Halo CR3BP patch point solution file !! example: 'data/L2_halos.json' logical :: patch_point_file_is_periapsis = .false. !! if the state in the patch point file are periapsis states !! (false means they are apoapsis states. !! the ones in L2_halos.json are apoapsis states) ! the initial guess for the Halo: ! This is for the "forward/backward" version of the transcription from the paper. type(patch_point) :: periapsis !! Patchpoint Periapse State type(patch_point) :: quarter !! Patchpoint 1/4 Rev State type(patch_point) :: apoapsis !! Patchpoint 1/2 Rev State real(wp) :: period = 0.0_wp !! Halo period [days] real(wp) :: period8 = 0.0_wp !! 1/8 of Halo period [days] ! optional problem inputs ! [can remove some of the variables from the optimization problem] logical :: fix_initial_time = .false. !! to fix the initial epoch in the mission logical :: fix_initial_r = .false. !! fix the initial periapsis position vector (x,y,z) integer :: fix_ry_at_end_of_rev = 0 !! fix ry at the end of the specified rev (at periapsis) !! not used if `<= 0`. logical :: fix_final_ry_and_vx = .false. !! fix ry and vx at the end of the last rev (at periapsis) integer :: solver_mode = 1 !! use sparse or dense solver: !! !! * 1 - dense (LAPACK) !! * 2 - sparse (LSQR) !! * 3 - sparse (LUSOL) !! * 4 - sparse (LMSR) !! * 5 - sparse (qr_mumps) contains procedure,public :: init => initialize_the_mission procedure,public :: plot => plot_trajectory procedure,public :: export_trajectory_json_file procedure,public :: write_optvars_to_file procedure,public :: constraint_violations procedure,public :: print_constraint_defects procedure,public :: generate_eclipse_data procedure :: get_problem_arrays procedure :: put_x_in_segments procedure :: get_x_from_json_file procedure :: get_scales_from_segs procedure :: segs_to_propagate procedure :: get_sparsity_pattern procedure :: define_problem_size procedure :: get_case_name procedure :: generate_patch_points procedure :: update_epoch end type mission_type