Skip to content
This repository was archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
Rearranged the solver and minimizer functions into their own misc mod…
Browse files Browse the repository at this point in the history
…ules
  • Loading branch information
daminton committed Dec 21, 2022
1 parent da3fe6f commit 8483f46
Show file tree
Hide file tree
Showing 13 changed files with 1,075 additions and 911 deletions.
2 changes: 2 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ SET(FAST_MATH_FILES
${SRC}/netcdf_io/netcdf_io_module.f90
${SRC}/misc/lambda_function_module.f90
${SRC}/misc/io_progress_bar_module.f90
${SRC}/misc/solver_module.f90
${SRC}/misc/minimizer_module.f90
${SRC}/encounter/encounter_module.f90
${SRC}/collision/collision_module.f90
${SRC}/fraggle/fraggle_module.f90
Expand Down
8 changes: 0 additions & 8 deletions src/encounter/encounter_module.f90
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ module encounter
integer(I4B) :: file_number = 1 !! The number to append on the output file
contains
procedure :: initialize => encounter_io_initialize_output !! Initialize a set of parameters used to identify a NetCDF output object
procedure :: open => encounter_netcdf_io_open
end type encounter_netcdf_parameters


Expand Down Expand Up @@ -230,13 +229,6 @@ module subroutine encounter_io_initialize_output(self, param)
class(base_parameters), intent(in) :: param
end subroutine encounter_io_initialize_output

module subroutine encounter_netcdf_io_open(self, param, readonly)
implicit none
class(encounter_netcdf_parameters), intent(inout) :: self !! Parameters used to identify a particular NetCDF dataset
class(base_parameters), intent(in) :: param !! Current run configuration parameters
logical, optional, intent(in) :: readonly !! Logical flag indicating that this should be open read only
end subroutine encounter_netcdf_io_open

module subroutine encounter_io_write_frame_snapshot(self, history, param)
implicit none
class(encounter_snapshot), intent(in) :: self !! Swiftest encounter structure
Expand Down
6 changes: 3 additions & 3 deletions src/fraggle/fraggle_generate.f90
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ subroutine fraggle_generate_tan_vel(collision_system, lfailure)

tol = TOL_INIT
do while(tol < TOL_MIN)
call swiftest_util_minimize_bfgs(objective_function, nfrag-6, v_t_initial(7:nfrag), tol, MAXLOOP, lfailure, v_t_output)
call minimize_bfgs(objective_function, nfrag-6, v_t_initial(7:nfrag), tol, MAXLOOP, lfailure, v_t_output)
fragments%v_t_mag(7:nfrag) = v_t_output(:)
! Now that the KE-minimized values of the i>6 fragments are found, calculate the momentum-conserving solution for tangential velociteis
v_t_initial(7:nfrag) = fragments%v_t_mag(7:nfrag)
Expand Down Expand Up @@ -495,7 +495,7 @@ function solve_fragment_tan_vel(lfailure, v_t_mag_input) result(v_t_mag_output)
b(1:3) = -L_lin_others(:)
b(4:6) = fragments%L_budget(:) - fragments%Lspin(:) - L_orb_others(:)
allocate(v_t_mag_output(nfrag))
v_t_mag_output(1:6) = swiftest_util_solve_linear_system(A, b, 6, lfailure)
v_t_mag_output(1:6) = solve_linear_system(A, b, 6, lfailure)
if (present(v_t_mag_input)) v_t_mag_output(7:nfrag) = v_t_mag_input(:)
end associate
end select
Expand Down Expand Up @@ -584,7 +584,7 @@ subroutine fraggle_generate_rad_vel(collision_system, lfailure)
objective_function = lambda_obj(radial_objective_function)
tol = TOL_INIT
do while(tol < TOL_MIN)
call swiftest_util_minimize_bfgs(objective_function, nfrag, v_r_initial, tol, MAXLOOP, lfailure, v_r_output)
call minimize_bfgs(objective_function, nfrag, v_r_initial, tol, MAXLOOP, lfailure, v_r_output)
fragments%v_r_mag(1:nfrag) = v_r_output(1:nfrag)
if (.not.lfailure) exit
tol = tol * 2 ! Keep increasing the tolerance until we converge on a solution
Expand Down
Loading

0 comments on commit 8483f46

Please sign in to comment.