Write the data for the solution plots (generate_solution_plots, see
python/plot_solution.py): for the initial guess and the solution, the epochs at
the constraint points (where segments 2k-1 and 2k end) and the defects there
(|dr|, |dv| in the rotating frame). The segments are left with the solution.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(mission_type), | intent(inout) | :: | me | |||
| character(len=*), | intent(in) | :: | filename |
the JSON file to write |
||
| real(kind=wp), | intent(in), | dimension(:) | :: | x_guess |
the initial guess (scaled) |
|
| real(kind=wp), | intent(in), | dimension(:) | :: | x |
the solution (scaled) |
subroutine write_solution_plot_data(me, filename, x_guess, x) class(mission_type),intent(inout) :: me character(len=*),intent(in) :: filename !! the JSON file to write real(wp),dimension(:),intent(in) :: x_guess !! the initial guess (scaled) real(wp),dimension(:),intent(in) :: x !! the solution (scaled) type(json_file) :: json real(wp),dimension(:),allocatable :: f, et_g, dr_g, dv_g, et_s, dr_s, dv_s integer :: m, n_segs call me%define_problem_size(m=m, n_segs=n_segs) allocate(f(m)) call evaluate(x_guess, et_g, dr_g, dv_g) call evaluate(x, et_s, dr_s, dv_s) ! (last: the segments are left with the solution) call json%initialize(compress_vectors=.true.) call json%add('case', me%get_case_name()) call json%add('et_ref', me%et_ref) call json%add('n_revs', me%n_revs) call json%add('epoch_variable_mode', me%epoch_variable_mode) call json%add('xscale_mode', me%xscale_mode) call json%add('jacobian_mode', me%jacobian_mode) call json%add('et_guess', et_g) ! [sec] call json%add('dr_guess', dr_g) ! [km] call json%add('dv_guess', dv_g) ! [km/s] call json%add('et_solution', et_s) call json%add('dr_solution', dr_s) call json%add('dv_solution', dv_s) call json%print(filename) call json%destroy() contains subroutine evaluate(xx, et, dr, dv) !! the epochs and defects at the constraint points for `xx` real(wp),dimension(:),intent(in) :: xx real(wp),dimension(:),allocatable,intent(out) :: et, dr, dv integer :: k call me%constraint_violations(xx, f) ! (propagates all the segments) f = f * me%fscale ! (unscaled: km and km/s) allocate(et(n_segs/2), dr(n_segs/2), dv(n_segs/2)) do k = 1, n_segs/2 associate (seg => me%segs(2*k-1)) et(k) = seg%data%et_ref + seg%data%tf*day2sec end associate dr(k) = norm2(f(6*k-5:6*k-3)) dv(k) = norm2(f(6*k-2:6*k)) end do end subroutine evaluate end subroutine write_solution_plot_data