Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Libphantom-amuse #513

Draft
wants to merge 18 commits into
base: master
Choose a base branch
from
Draft

Libphantom-amuse #513

wants to merge 18 commits into from

Conversation

rieder
Copy link
Contributor

@rieder rieder commented Feb 22, 2024

Type of PR:
new code: library for using Phantom with AMUSE

Description:

  • introduce a write_files option, defaults to .true.
  • make write/open/close statements conditional on write_files
  • introduce utils/libphantom-amuse.F90, with helper subroutines for the AMUSE interface

Testing:
WIP

Did you run the bots? yes/no

Did you update relevant documentation in the docs directory? yes/no

call set_io_unit_numbers()
call initialise()
call amuse_set_defaults() ! replaces reading infile
call set_units(dist=1 * au,mass=1.*solarm,G=1.)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one option here is to send strings for the units, then call select_unit(mass_unit,umass,ierr) to get the unit from the string

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is inside setup/set_units.f90


end subroutine amuse_initialize_code_new

subroutine amuse_initialize_code()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we delete this if obsolete?

!call amuse_initialize_wind()
end subroutine amuse_initialize_code

subroutine amuse_set_phantom_option(name, valstring, imatch)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this could in principle be done in a more automated way, if we were to read the infile like setup files... this is on my list (should create an issue on this to get this task done)

use deriv, only:derivs
use part, only:npart,xyzh,vxyzu,fxyzu,fext,divcurlv,divcurlB,Bevol,dBevol,&
dustprop,ddustprop,dustfrac,ddustevol,dens,drad,radprop,dustevol,&
eos_vars,metrics,pxyzu,rad
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can just call get_derivs_global() here which calls derivs, then the interface to derivs would not need updating. This can be found in the derivs module and is used in the test suite

if (nodisabled) then
npart_out = 0
do i=1,npart
if (xyzh(4,i) > 0.) then
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this condition should be a call to isdead_or_accreted(xyzh(4,i)) for consistency with the other code


! This initialises things. This really should only be called once, before the first step.
subroutine amuse_evol(amuse_initialise)
use io, only:iprint,iwritein,id,master,iverbose,&
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be removed and replaced by a call to evol but with some flags needed for amuse to behave correctly

call kill_particle(i)
else
j = -i
! Sink particles can't be killed - so we just set its mass to zero
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sink particles can be killed by giving them a negative mass, suggest xyzmh_ptmass(4,i) = -abs(xyzmh_ptmass(4,i))

endif
end subroutine

subroutine amuse_get_unit_length(unit_length_out)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should not be a need for these routines, as long as set_units() is called during the amuse_initialize_code_new routine, and if you can send strings to set different options

dtextforce = 1.e-8
end subroutine

subroutine amuse_evolve_model(tmax_in)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see previous, should be just a call to evolve

udist_out = udist
end subroutine

! End of Getters
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please delete commented out/ obsolete code

rieder added 4 commits October 4, 2024 12:15
- option not to write files
- initialise only on the first call to evol
- create, use and update a map to the original particle ids to ensure AMUSE identifies the right particles
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants