Skip to content

Commit

Permalink
Merge pull request #503 from Fitz-Hu/master
Browse files Browse the repository at this point in the history
Inject particles from another simulation
  • Loading branch information
danieljprice committed May 16, 2024
2 parents 3e80784 + 5f774a8 commit 451baf5
Show file tree
Hide file tree
Showing 24 changed files with 1,262 additions and 141 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,7 @@ build/phantom-version.h
*.tar
.DS_Store
_build
*.cmdx
*.cmod
*.ilm
*.stb
4 changes: 2 additions & 2 deletions build/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -533,8 +533,8 @@ SOURCES= physcon.f90 ${CONFIG} ${SRCKERNEL} io.F90 units.f90 \
mpi_memory.f90 mpi_derivs.F90 mpi_tree.F90 kdtree.F90 linklist_kdtree.F90 utils_healpix.f90 utils_raytracer.f90 \
partinject.F90 utils_inject.f90 dust_formation.f90 ptmass_radiation.f90 ptmass_heating.f90 \
utils_deriv.f90 utils_implicit.f90 radiation_implicit.f90 ${SRCTURB} \
${SRCINJECT_DEPS} wind_equations.f90 wind.F90 ${SRCINJECT} \
${SRCKROME} memory.f90 ${SRCREADWRITE_DUMPS} \
${SRCINJECT_DEPS} wind_equations.f90 wind.F90 \
${SRCKROME} memory.f90 ${SRCREADWRITE_DUMPS} ${SRCINJECT} \
utils_subgroup.f90 utils_kepler.f90 subgroup.f90\
quitdump.f90 ptmass.F90 \
readwrite_infile.F90 dens.F90 force.F90 deriv.F90 energies.F90 sort_particles.f90 \
Expand Down
1 change: 1 addition & 0 deletions build/Makefile_setups
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ ifeq ($(SETUP), radiotde)
IND_TIMESTEPS=no
ANALYSIS=analysis_radiotde.f90
MODFILE=moddump_radiotde.f90
SRCINJECT=inject_sim.f90
SYSTEM=gfortran
endif

Expand Down
73 changes: 73 additions & 0 deletions docs/inject_sim.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@

Injecting particles from existing simulations to new simulations
=========================================================

Initial setup
-------------

To ensure the particle mass and units are consistent in both existing & new simulations,
it is recommended to use 'phantommoddump' with existing simulations to setup new simulations

::

make SRCINJECT=inject_sim.f90; make moddump SRCINJECT=inject_sim.f90
./phantommoddump YOUR_EXISTING_SIMULATION YOUR_NEW_SIMULATION TIME

'phantommodump' might produce a parameter file depending on the setup,
in that case one would need to run
::
./phantommoddump YOUR_EXISTING_SIMULATION YOUR_NEW_SIMULATION TIME'

one more time after setting up the parameters

At the end of these instructions, an initial dump of the new simulaton and a .in file are created.

::

Content of the .in file
--------------------------

Options controlling particle injection
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

::

# options controlling particle injection
start_dump = 'dump_00000' ! dumpfile to start for injection
r_inject = 5.000E+14 ! radius to inject tde outflow (in cm)
final_dump = 'dump_02000' ! stop injection after this dump

Here’s a brief description of each of them

::

start_dump = 'dump_00000' ! dumpfile to start for injection

set the dump start to inject. The code will check the start_dump time and start injection when the time is reached in new simulations
Once a dump is used by injection, the dump number will automatically increased by 1. The new dump is written to .in file once a full dump is saved

If the dumps are in a different directory,

::

start_dump = 'PATH/TO/YOUR/OTHER/DIR/dump_00000' ! dumpfile to start for injection

can read dumps from other directory. The path needs to be the RELATIVE path to the working directory
!!!--------------------------------------!!!
NOTE: qotation marks are NECESSARY with path
!!!--------------------------------------!!!

::

r_inject = 5.000E+14 ! radius to inject tde outflow (in cm)

set the radius for inject. For TDE outflow specifically, once a particle pass this radius from inside to outside in the existing simulations, it is injected to the new simulations

::

final_dump = 'dump_02000' ! stop injection after this dump

set the dump to stop injection. The injection dump number keep increasing by 1 after each injection and will stop once reaching this set final_dump.
If there is a PATH in start_dump, it is NECESSARY in final_dump as well.

7 changes: 6 additions & 1 deletion src/main/inject_BHL.f90
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ module inject
character(len=*), parameter, public :: inject_type = 'BHL'

public :: init_inject,inject_particles,write_options_inject,read_options_inject,&
set_default_options_inject
set_default_options_inject,update_injected_par
!
!--runtime settings for this module
!
Expand Down Expand Up @@ -261,6 +261,11 @@ subroutine inject_or_update_particles(ifirst, n, position, velocity, h, u, bound

end subroutine inject_or_update_particles

subroutine update_injected_par
! -- placeholder function
! -- does not do anything and will never be used
end subroutine

!-----------------------------------------------------------------------
!+
! Writes input options to the input file
Expand Down
7 changes: 6 additions & 1 deletion src/main/inject_asteroidwind.f90
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ module inject
real, public :: mdot = 5.e8 ! mass injection rate in grams/second

public :: init_inject,inject_particles,write_options_inject,read_options_inject,&
set_default_options_inject
set_default_options_inject,update_injected_par

private

Expand Down Expand Up @@ -149,6 +149,11 @@ subroutine inject_particles(time,dtlast,xyzh,vxyzu,xyzmh_ptmass,vxyz_ptmass,&

end subroutine inject_particles

subroutine update_injected_par
! -- placeholder function
! -- does not do anything and will never be used
end subroutine

!-----------------------------------------------------------------------
!+
! Returns dndt(t) depending on which function is chosen
Expand Down
7 changes: 6 additions & 1 deletion src/main/inject_bondi.f90
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ module inject
inject_particles, &
write_options_inject, &
read_options_inject, &
set_default_options_inject
set_default_options_inject, &
update_injected_par

!-- Runtime variables read from input file
real, public :: rin = 18.1
Expand Down Expand Up @@ -216,6 +217,10 @@ subroutine inject_particles(time,dtlast,xyzh,vxyzu,xyzmh_ptmass,vxyz_ptmass,&

end subroutine inject_particles

subroutine update_injected_par
! -- placeholder function
! -- does not do anything and will never be used
end subroutine

!-----------------------------------------------------------------------
!+
Expand Down
6 changes: 5 additions & 1 deletion src/main/inject_firehose.f90
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module inject
character(len=*), parameter, public :: inject_type = 'firehose'

public :: inject_particles, write_options_inject, read_options_inject
public :: init_inject, set_default_options_inject
public :: init_inject, set_default_options_inject, update_injected_par

real, private :: Mdot = 0.
real, private :: Mdotcode = 0.
Expand Down Expand Up @@ -210,6 +210,10 @@ end function Mdotfunc

end subroutine inject_particles

subroutine update_injected_par
! -- placeholder function
! -- does not do anything and will never be used
end subroutine

!-----------------------------------------------------------------------
!+
Expand Down
7 changes: 6 additions & 1 deletion src/main/inject_galcen_winds.f90
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module inject
character(len=*), parameter, public :: inject_type = 'galcen_winds'

public :: init_inject,inject_particles,write_options_inject,read_options_inject,&
set_default_options_inject
set_default_options_inject,update_injected_par

real :: outer_boundary = 20.
character(len=120) :: datafile = 'winddata.txt'
Expand Down Expand Up @@ -223,6 +223,11 @@ subroutine inject_particles(time,dtlast,xyzh,vxyzu,xyzmh_ptmass,vxyz_ptmass,&

end subroutine inject_particles

subroutine update_injected_par
! -- placeholder function
! -- does not do anything and will never be used
end subroutine

!-----------------------------------------------------------------------
!+
! Writes input options to the input file.
Expand Down
7 changes: 6 additions & 1 deletion src/main/inject_keplerianshear.f90
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ module inject
character(len=*), parameter, public :: inject_type = 'keplerianshear'

public :: init_inject,inject_particles,write_options_inject,read_options_inject,&
set_default_options_inject
set_default_options_inject,update_injected_par
public :: set_injection_parameters

type injectparams
Expand Down Expand Up @@ -186,6 +186,11 @@ subroutine inject_particles(time,dtlast,xyzh,vxyzu,xyzmh_ptmass,vxyz_ptmass,&

end subroutine inject_particles

subroutine update_injected_par
! -- placeholder function
! -- does not do anything and will never be used
end subroutine

!-----------------------------------------------------------------------
!+
! Writes input options to the input file
Expand Down
6 changes: 5 additions & 1 deletion src/main/inject_rochelobe.f90
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ module inject
character(len=*), parameter, public :: inject_type = 'rochelobe'

public :: init_inject,inject_particles,write_options_inject,read_options_inject,&
set_default_options_inject
set_default_options_inject,update_injected_par

real, private :: Mdot = 1.0e-9
real, private :: Mdotcode = 0.
Expand Down Expand Up @@ -278,6 +278,10 @@ subroutine phi_derivs(phinns,phizzs,xyzL1,xx1,xx2,theta_s,m1,m2,mu,r12,Porb)

end subroutine phi_derivs

subroutine update_injected_par
! -- placeholder function
! -- does not do anything and will never be used
end subroutine

!-----------------------------------------------------------------------
!+
Expand Down
Loading

0 comments on commit 451baf5

Please sign in to comment.