get_problem_arrays Subroutine

public subroutine get_problem_arrays(me, x, f)

Get the arrays for the problem

Type Bound

mission_type

Arguments

Type IntentOptional 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


Calls

proc~~get_problem_arrays~~CallsGraph proc~get_problem_arrays mission_type%get_problem_arrays fill_vector fill_vector proc~get_problem_arrays->fill_vector

Called by

proc~~get_problem_arrays~~CalledByGraph proc~get_problem_arrays mission_type%get_problem_arrays proc~constraint_violations mission_type%constraint_violations proc~constraint_violations->proc~get_problem_arrays proc~initialize_the_mission mission_type%initialize_the_mission proc~initialize_the_mission->proc~get_problem_arrays proc~print_constraint_defects mission_type%print_constraint_defects proc~print_constraint_defects->proc~get_problem_arrays proc~halo_solver_main halo_solver_main proc~halo_solver_main->proc~constraint_violations proc~halo_solver_main->proc~print_constraint_defects proc~initialize_the_solver my_solver_type%initialize_the_solver proc~halo_solver_main->proc~initialize_the_solver proc~initialize_the_solver->proc~initialize_the_mission

Source Code

    subroutine get_problem_arrays(me,x,f)

    implicit none

    class(mission_type),intent(in) :: me
    real(wp),dimension(:),intent(out),optional :: x !! opt var vector [scaled]
    real(wp),dimension(:),intent(out),optional :: f !! constraint violations

    integer :: i          !! counter for index in `x`
    integer :: irev       !! counter for number of revs
    integer :: iseg       !! segment number counter

    if (present(x)) then

        x = -huge(1.0_wp) ! just in case we miss one

        i = 0 ! initialize the index. will be updated by fill_vector
        iseg = 0
        do irev = 1, me%n_revs

            if (irev==1) then

                ! the first one has an extra opt point at the initial periapsis passage

                if (.not. me%fix_initial_time) &
                call fill_vector(x, me%segs(iseg+1)%data%t0, i)

                if (me%fix_initial_r) then
                    call fill_vector(x, me%segs(iseg+1)%data%x0_rotating(4:6), i) ! v only
                else
                    call fill_vector(x, me%segs(iseg+1)%data%x0_rotating, i) ! r,v
                end if

                call fill_vector(x, me%segs(iseg+2)%data%t0, i)
                call fill_vector(x, me%segs(iseg+2)%data%x0_rotating, i)

                call fill_vector(x, me%segs(iseg+4)%data%t0, i)
                call fill_vector(x, me%segs(iseg+4)%data%x0_rotating, i)

                call fill_vector(x, me%segs(iseg+6)%data%t0, i)
                call fill_vector(x, me%segs(iseg+6)%data%x0_rotating, i)

                call fill_vector(x, me%segs(iseg+8)%data%t0, i)

                if (me%fix_ry_at_end_of_rev == 1) then
                    call fill_vector(x, me%segs(iseg+8)%data%x0_rotating([1,3,4,5,6]), i)
                else
                    call fill_vector(x, me%segs(iseg+8)%data%x0_rotating, i)
                end if

                ! for next rev:
                iseg = iseg + 8

            else

                call fill_vector(x, me%segs(iseg+2)%data%t0, i)
                call fill_vector(x, me%segs(iseg+2)%data%x0_rotating, i)

                call fill_vector(x, me%segs(iseg+4)%data%t0, i)
                call fill_vector(x, me%segs(iseg+4)%data%x0_rotating, i)

                call fill_vector(x, me%segs(iseg+6)%data%t0, i)
                call fill_vector(x, me%segs(iseg+6)%data%x0_rotating, i)

                call fill_vector(x, me%segs(iseg+8)%data%t0, i)

                if (me%fix_ry_at_end_of_rev == irev) then
                    call fill_vector(x, me%segs(iseg+8)%data%x0_rotating([1,3,4,5,6]), i)
                elseif (irev==me%n_revs .and. me%fix_final_ry_and_vx) then
                    call fill_vector(x, me%segs(iseg+8)%data%x0_rotating([1,3,5,6]), i)
                else
                    call fill_vector(x, me%segs(iseg+8)%data%x0_rotating, i)
                end if

                ! for next rev:
                iseg = iseg + 8

            end if

        end do

        ! scale the x vector:
        x = x / me%xscale

    end if

    if (present(f)) then

        ! f = [xf1-xf2, xf3-xf4, xf5-xf6, xf7-xf8, ... ]

        i = 0
        iseg = 0
        do irev = 1, me%n_revs

            call fill_vector(f, -(me%segs(iseg+1)%data%xf_rotating - me%segs(iseg+2)%data%xf_rotating), i)
            call fill_vector(f, -(me%segs(iseg+3)%data%xf_rotating - me%segs(iseg+4)%data%xf_rotating), i)
            call fill_vector(f, -(me%segs(iseg+5)%data%xf_rotating - me%segs(iseg+6)%data%xf_rotating), i)
            call fill_vector(f, -(me%segs(iseg+7)%data%xf_rotating - me%segs(iseg+8)%data%xf_rotating), i)

            iseg = iseg + 8

        end do

        !scale the f vector:
        f = f / me%fscale

    end if

    end subroutine get_problem_arrays