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
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions build/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -859,6 +859,26 @@ libphantom: libphantom.a
cleanlibphantom:
rm -f $(BINDIR)/libphantom.so $(LIBPHANTOM)

.PHONY: libphantom-amuse
# extra files used in libphantom that are not in OBJECTS
SRCLIB= libphantom-amuse.F90
OBJLIB1=${SRCLIB:.f90=.o}
OBJLIB=${OBJLIB1:.F90=.o}

LIBPHANTOMAMUSE=$(BINDIR)/libphantom-amuse.a

libphantom-amuse.a: checksystem checkparams $(OBJECTS) $(OBJLIB)
ar rc $(LIBPHANTOMAMUSE) $(OBJLIB) $(OBJECTS)

libphantom-amuse.so: checksystem checkparams phantom ${OBJLIB}
$(FC) -shared $(FFLAGS) $(FPPFLAGS) $(DBLFLAG) ${OBJLIB} ${OBJECTS} $(LDFLAGS) -o $(BINDIR)/libphantom-amuse.so

libphantom-amuse: libphantom-amuse.a

cleanlibphantom:
rm -f $(BINDIR)/libphantom-amuse.so $(LIBPHANTOMAMUSE)


.PHONY: pyanalysis
pyanalysis: libphantom.so

Expand Down
17 changes: 17 additions & 0 deletions build/Makefile_setups
Original file line number Diff line number Diff line change
Expand Up @@ -1122,3 +1122,20 @@ ifeq ($(SETUP), radiativebox)
RADIATION=yes
PERIODIC=yes
endif

ifeq ($(SETUP), amuse)
FPPFLAGS=-DAMUSE
# H2CHEM=yes
ISOTHERMAL=no
GRAVITY=yes
# IND_TIMESTEPS=yes
IND_TIMESTEPS=no
KNOWN_SETUP=yes
MAXPTMASS=1000
MAXP=10000000
SETUPFILE= setup_wind.f90
# ANALYSIS= utils_getneighbours.f90 utils_raytracer_all.f90 analysis_raytracer.f90
SINK_RADIATION=yes
DUST_NUCLEATION=yes
INJECT_PARTICLES=yes
endif
7 changes: 4 additions & 3 deletions src/main/evwrite.f90
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ module evwrite
subroutine init_evfile(iunit,evfile,open_file)
use io, only:id,master,warning
use dim, only:maxtypes,maxalpha,maxp,maxp_hard,mhd,mhd_nonideal,lightcurve
use options, only:calc_erot,ishock_heating,ipdv_heating,use_dustfrac
use options, only:calc_erot,ishock_heating,ipdv_heating,use_dustfrac,write_files
use units, only:c_is_unity
use part, only:igas,idust,iboundary,istar,idarkmatter,ibulge,npartoftype,ndusttypes,maxtypes
use nicil, only:use_ohm,use_hall,use_ambi
Expand Down Expand Up @@ -234,7 +234,7 @@ subroutine init_evfile(iunit,evfile,open_file)
!--all threads do above, but only master writes file
! (the open_file is to prevent an .ev file from being made during the test suite)
!
if (open_file .and. id == master) then
if (write_files .and. open_file .and. id == master) then
!
!--open the file for output
!
Expand Down Expand Up @@ -351,7 +351,7 @@ subroutine write_evfile(t,dt)
use energies, only:compute_energies,ev_data_update
use io, only:id,master,ievfile
use timestep, only:dtmax_user
use options, only:iexternalforce
use options, only:iexternalforce,write_files
use externalforces,only:accretedmass1,accretedmass2
real, intent(in) :: t,dt
integer :: i,j
Expand All @@ -360,6 +360,7 @@ subroutine write_evfile(t,dt)

call compute_energies(t)

if (.not. write_files) return
if (id==master) then
!--fill in additional details that are not calculated in energies.f
ev_data(iev_sum,iev_dt) = dt
Expand Down
22 changes: 13 additions & 9 deletions src/main/initial.F90
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ subroutine startrun(infile,logfile,evfile,dumpfile,noread)
die,fatal,id,master,nprocs,real4,warning,iverbose
use externalforces, only:externalforce,initialise_externalforces,update_externalforce,&
externalforce_vdependent
use options, only:iexternalforce,icooling,use_dustfrac,rhofinal1,rhofinal_cgs
use options, only:iexternalforce,icooling,use_dustfrac,rhofinal1,rhofinal_cgs,write_files
use readwrite_infile, only:read_infile,write_infile
use readwrite_dumps, only:read_dump,write_fulldump
use part, only:npart,xyzh,vxyzu,fxyzu,fext,divcurlv,divcurlB,Bevol,dBevol,tau, tau_lucy, &
Expand Down Expand Up @@ -569,6 +569,7 @@ subroutine startrun(infile,logfile,evfile,dumpfile,noread)
#ifdef INJECT_PARTICLES
call init_inject(ierr)
if (ierr /= 0) call fatal('initial','error initialising particle injection')
if (write_files) then
!rename wind profile filename
inquire(file='wind_profile1D.dat',exist=iexist)
if (iexist) then
Expand All @@ -580,6 +581,7 @@ subroutine startrun(infile,logfile,evfile,dumpfile,noread)
endif
call rename('wind_profile1D.dat',trim(file1D))
endif
endif
npart_old = npart
call inject_particles(time,0.,xyzh,vxyzu,xyzmh_ptmass,vxyz_ptmass,&
npart,npart_old,npartoftype,dtinject)
Expand Down Expand Up @@ -656,22 +658,22 @@ subroutine startrun(infile,logfile,evfile,dumpfile,noread)
!
if (id==master .and. read_input_files) call write_header(2,infile,evfile,logfile,dumpfile,ntot)

call init_evfile(ievfile,evfile,.true.)
if (write_files) call init_evfile(ievfile,evfile,.true.)
call write_evfile(time,dt)
if (id==master) call write_evlog(iprint)
if (write_files .and. id==master) call write_evlog(iprint)
#ifdef MFLOW
call mflow_init(imflow,evfile,infile) !take evfile in input to create string.mf
call mflow_write(time, dt)
if (write_files) call mflow_init(imflow,evfile,infile) !take evfile in input to create string.mf
if (write_files) call mflow_write(time, dt)
#endif

#ifdef VMFLOW
call vmflow_init(ivmflow,evfile,infile) !take evfile in input to create string_v.mflowv
call vmflow_write(time, dt)
if (write_files) call vmflow_init(ivmflow,evfile,infile) !take evfile in input to create string_v.mflowv
if (write_files) call vmflow_write(time, dt)
#endif

#ifdef BINPOS
call binpos_init(ibinpos,evfile) !take evfile in input to create string.binpos
call binpos_write(time, dt)
if (write_files) call binpos_init(ibinpos,evfile) !take evfile in input to create string.binpos
if (write_files) call binpos_write(time, dt)
#endif
!
!--Determine the maximum separation of particles
Expand Down Expand Up @@ -775,6 +777,7 @@ subroutine startrun(infile,logfile,evfile,dumpfile,noread)
!--write initial conditions to output file
! if the input file ends in .tmp or .init
!
if (write_files) then
iposinit = index(dumpfile,'.init')
ipostmp = index(dumpfile,'.tmp')
if (iposinit > 0 .or. ipostmp > 0) then
Expand All @@ -801,6 +804,7 @@ subroutine startrun(infile,logfile,evfile,dumpfile,noread)
close(unit=idisk1,status='delete')
endif
endif
endif ! (write_files)

if (id==master) then
call flush_warnings()
Expand Down
8 changes: 7 additions & 1 deletion src/main/options.f90
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,13 @@ module options
real(kind=sp), public :: mcfost_keep_part
character(len=80), public :: Voronoi_limits_file

! radiation
! radiation
logical, public :: exchange_radiation_energy, limit_radiation_flux, implicit_radiation
logical, public :: implicit_radiation_store_drad

! library use
logical, public :: write_files

public :: set_default_options
public :: ieos,idamp
public :: iopacity_type
Expand Down Expand Up @@ -169,6 +172,9 @@ subroutine set_default_options
! variable composition
use_var_comp = .false.

! for use as a library
write_files = .true.

end subroutine set_default_options

end module options
3 changes: 3 additions & 0 deletions src/main/ptmass.F90
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ module ptmass
use part, only:nsinkproperties,gravity,is_accretable,&
ihsoft,ihacc,ispinx,ispiny,ispinz,imacc,iJ2,iReff
use io, only:iscfile,iskfile,id,master
use options, only:write_files
implicit none

public :: init_ptmass, finish_ptmass
Expand Down Expand Up @@ -1706,6 +1707,7 @@ subroutine init_ptmass(nptmass,logfile)
integer :: i,idot
character(len=150) :: filename

if (.not. write_files) return
if (id /= master) return ! only do this on master thread
!
!--Extract prefix & suffix
Expand Down Expand Up @@ -1782,6 +1784,7 @@ subroutine pt_open_sinkev(num)
integer :: iunit
character(len=200) :: filename

if (.not. write_files) return
if (id /= master) return ! only do this on master thread

if (write_one_ptfile) then
Expand Down
1 change: 1 addition & 0 deletions src/main/timestep.f90
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ module timestep
real :: dtmax_dratio, dtmax_max, dtmax_min, rhomaxnow
real(kind=4) :: dtwallmax
integer :: dtmax_ifactor,dtmax_ifactorWT
real :: dtlast

public

Expand Down
14 changes: 8 additions & 6 deletions src/main/wind.F90
Original file line number Diff line number Diff line change
Expand Up @@ -929,6 +929,7 @@ subroutine save_windprofile(r0, v0, T0, rout, tend, tcross, filename)
use physcon, only:au
use dust_formation, only:idust_opacity
use ptmass_radiation, only:iget_tdust
use options, only:write_files
real, intent(in) :: r0, v0, T0, tend, rout
real, intent(out) :: tcross !time to cross the entire integration domain
character(*), intent(in) :: filename
Expand All @@ -953,10 +954,11 @@ subroutine save_windprofile(r0, v0, T0, rout, tend, tcross, filename)
else
call init_wind(r0, v0, T0, tend, state)
endif

open(unit=1337,file=filename)
call filewrite_header(1337,nwrite)
call filewrite_state(1337,nwrite, state)
if (write_files) then
open(unit=1337,file=filename)
call filewrite_header(1337,nwrite)
call filewrite_state(1337,nwrite, state)
endif

eps = 0.01
iter = 0
Expand Down Expand Up @@ -987,7 +989,7 @@ subroutine save_windprofile(r0, v0, T0, rout, tend, tcross, filename)
.or. ( abs((mu_incr -mu_base) /mu_base) > eps ) ) then

writeline = writeline + 1
call filewrite_state(1337,nwrite, state)
if (write_files) call filewrite_state(1337,nwrite, state)

r_base = state%r
v_base = state%v
Expand All @@ -1007,7 +1009,7 @@ subroutine save_windprofile(r0, v0, T0, rout, tend, tcross, filename)
else
print *,'integration successful, #',iter,' iterations required, rout = ',state%r/au
endif
close(1337)
if (write_files) close(1337)
!stop 'save_windprofile'

if (allocated(trvurho_1D)) deallocate(trvurho_1D)
Expand Down
Loading
Loading