Skip to content

Commit

Permalink
Merge branch 'master' of github.com:danieljprice/phantom
Browse files Browse the repository at this point in the history
  • Loading branch information
danieljprice committed May 8, 2023
2 parents c0af43a + a7381be commit f80548b
Show file tree
Hide file tree
Showing 46 changed files with 1,210 additions and 530 deletions.
8 changes: 4 additions & 4 deletions build/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -655,10 +655,10 @@ libsetup: $(OBJLIBSETUP)
.PHONY: phantomsetup
phantomsetup: setup

SRCSETUP= prompting.f90 set_dust_options.f90 \
density_profiles.f90 set_slab.f90 set_disc.F90 \
SRCSETUP= prompting.f90 set_dust_options.f90 set_units.f90 \
density_profiles.f90 readwrite_kepler.f90 readwrite_mesa.f90 \
set_slab.f90 set_disc.F90 \
set_cubic_core.f90 set_fixedentropycore.f90 set_softened_core.f90 \
set_star_kepler.f90 set_star_mesa.f90 \
set_star_utils.f90 relax_star.f90 set_star.f90 set_hierarchical.f90 \
set_vfield.f90 set_Bfield.f90 \
${SETUPFILE}
Expand Down Expand Up @@ -796,7 +796,7 @@ interpolate3D_amr.o: adaptivemesh.o
ifndef MODDUMPBIN
MODDUMPBIN=phantommoddump
endif
OBJMOD1 = prompting.o set_Bfield.o density_profiles.o set_star_mesa.o ${MODFILE:.f90=.o} phantom_moddump.o
OBJMOD1 = prompting.o set_Bfield.o density_profiles.o readwrite_mesa.o ${MODFILE:.f90=.o} phantom_moddump.o
OBJMOD = ${OBJMOD1:.F90=.o}

phantom_moddump: checksystem checkparams libphantom libsetup $(OBJMOD)
Expand Down
10 changes: 6 additions & 4 deletions build/Makefile_setups
Original file line number Diff line number Diff line change
Expand Up @@ -702,18 +702,19 @@ ifeq ($(SETUP), cluster)
endif

ifeq ($(SETUP), binary)
# binary setup
FPPFLAGS= -DCONST_AV
# binary stars
FPPFLAGS=
#SRCINJECT= utils_binary.f90 set_binary.f90 inject_rochelobe.f90
SETUPFILE= setup_binary.f90
#SETUPFILE= setup_chinchen.f90
KNOWN_SETUP=yes
GRAVITY=yes
endif

ifeq ($(SETUP), hierarchical)
# hierarchical system setup
FPPFLAGS= -DCONST_AV
#SRCINJECT= set_hierarchical.f90 set_binary.f90 inject_rochelobe.f90 utils_binary.f90
#SRCINJECT= set_hierarchical.f90 set_binary.f90 inject_rochelobe.f90 utils_binary.f90
SETUPFILE= setup_hierarchical.f90
KNOWN_SETUP=yes
endif
Expand All @@ -738,7 +739,7 @@ ifeq ($(SETUP), star)
endif

ifeq ($(SETUP), grstar)
# import stellar model from 1D stellar evolution code in GR using Minkowski metric
# star in GR using Minkowski metric
GR=yes
METRIC=minkowski
FPPFLAGS=
Expand Down Expand Up @@ -843,6 +844,7 @@ ifeq ($(SETUP), jetnimhd)
endif

ifeq ($(SETUP), jetdusty)
# dust in star formation
SETUPFILE= velfield_fromcubes.f90 setup_sphereinbox.f90
PERIODIC=yes
GRAVITY=yes
Expand Down
160 changes: 116 additions & 44 deletions docs/binary.rst
Original file line number Diff line number Diff line change
@@ -1,78 +1,150 @@
How to set up and run a common envelope binary simulation
=========================================================
Binary stars and common envelopes
==================================

Use SETUP=star::
Using SETUP=binary
------------------
The one-stop-shop to setup a binary star simulation is to use SETUP=binary::

~/phantom/scripts/writemake.sh star > Makefile
~/phantom/scripts/writemake.sh binary > Makefile

::

make setup
./phantomsetup star
./phantomsetup sim

Will create star.in. Set the following options::
```
-----------------------------------------------------------------
Welcome to the Ultimate Binary Setup
-----------------------------------------------------------------

tmax = 4000. ! end time
dtmax = 50. ! time between dumps
...
alpha = 1.000 ! MINIMUM art. viscosity parameter (max = 1.0)
alphau = 1.000 ! art. conductivity parameter
...
damp = 0.030 ! artificial damping of velocities (if on, v=0 initially)
...
ishock_heating = 0 ! shock heating (0=off, 1=on)
...
icreate_sinks = 1 ! allow automatic sink particle creation
rho_crit_cgs = 10. ! density above which sink particles are created (g/cm^3)
r_crit = 1.000E+04 ! critical radius for point mass creation (no new sinks < r_crit from existing sink)
h_acc = 0.030 ! accretion radius for new sink particles
hsoft = 1.000 ! softening length for sink particles (Plummer)
f_acc = 1.000 ! particles < f_acc*h_acc accreted without checks
writing setup options file binary.setup
Edit sim.setup and rerun phantomsetup
```

Run this to completion::
Will create sim.setup which contains setup options.

make
./phantom star.in

Then compile phantommoddump:
Two sink particles in orbit
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The simplest is to setup two sink particles in a binary (iprofile=0), by amending the iprofile flags::

::
# options for star 1
iprofile1 = 0 ! 0=Sink,1=Unif,2=Poly,3=Dens,4=KEPL,5=MESA,6=Pie

make moddump
# options for star 2
iprofile2 = 0 ! 0=Sink,1=Unif,2=Poly,3=Dens,4=KEPL,5=MESA,6=Pie

and run it:
Then run phantomsetup again to rewrite the required options::

::
$ ./phantomsetup sim

./phantommoddump star_00080 binary_00000.tmp 0.0
which will give::

Now you’re ready to run the binary calculation. Use
ERROR: hacc1 not found
ERROR: hacc2 not found
2 error(s) during read of setup file: re-writing...
writing setup options file sim.setup
Edit sim.setup and rerun phantomsetup

::
Run this again to finish the setup::

./phantomsetup binary.in
./phantomsetup sim

to create a binary.in file, and then change the file as follows
This creates a sim.in file for the main code. You should edit the tmax and dtmax
to give the desired finishing time (tmax) and time between snapshots (dtmax)::

::
cat sim.in

dumpfile = binary_00000.tmp ! dump file to start from
dumpfile = sim_00000.tmp ! dump file to start from
...
tmax = 200000. ! end time
dtmax = 50. ! time between dumps **These are fairly arbitrary. Depends on desired simulation**
dtmax = 50. ! time between dumps
...
alpha = 0.100 ! MINIMUM art. viscosity parameter (max = 1.0)
alpha = 0.000 ! MINIMUM art. viscosity parameter (max = 1.0)
alphau = 1.000 ! art. conductivity parameter
...
icreate_sinks = 0 ! allow automatic sink particle creation
f_acc = 0.500 ! particles < f_acc*h_acc accreted without checks

Once changed, run

After editing the .in file, proceed to run the simulation

make
./phantom sim

and have a look at the outputs with splash:

::

splash sim_0*


Two polytropes in orbit
~~~~~~~~~~~~~~~~~~~~~~~~~
The default is to setup-and-relax two polytropes and place them in orbit. For this edit
your sim.setup file to give::

# options for star 1
iprofile1 = 2 ! 0=Sink,1=Unif,2=Poly,3=Dens,4=KEPL,5=MESA,6=Pie
Mstar1 = 1.000 ! mass of star1
Rstar1 = 1.000 ! radius of star1
np1 = 1000 ! number of particles

# options for star 2
iprofile2 = 2 ! 0=Sink,1=Unif,2=Poly,3=Dens,4=KEPL,5=MESA,6=Pie
Mstar2 = 1.000 ! mass of star2
Rstar2 = 1.000 ! radius of star2

Then run phantomsetup again to rewrite the required options::

$ ./phantomsetup sim

This time you should see the automated relax-a-star procedure kick in::

RELAX-A-STAR-O-MATIC: Etherm: 0.463 Epot: -0.822 R*: 1.00
WILL stop WHEN: dens error < 1.00% AND Ekin/Epot < 1.000E-07 OR Iter=1000
Relaxing star: Iter 1/1000, dens error: 13.72%, R*: 0.924 Ekin/Epot: 3.398E-03
Relaxing star: Iter 2/1000, dens error: 10.97%, R*: 0.915 Ekin/Epot: 4.673E-03
...

As previously, you can then just proceed to run the simulation after editing the sim.in file
::

./phantom binary.in
./phantom sim.in

Two stars from MESA profiles
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To use stellar profiles from the MESA code, select iprofile=5 in your .setup file
and enter the name of the ascii data file containing the input profile
(most files produced by MESA just work...)::

# options for star 1
iprofile1 = 5 ! 0=Sink,1=Unif,2=Poly,3=Dens,4=KEPL,5=MESA,6=Pie
input_profile1 = P12_Phantom_Profile.data ! Path to input profile
isoftcore1 = 0 ! 0=no core softening, 1=cubic, 2=const. entropy
isinkcore1 = F ! Add a sink particle stellar core
np1 = 1000000 ! number of particles

# options for star 2
iprofile2 = 5 ! 0=Sink,1=Unif,2=Poly,3=Dens,4=KEPL,5=MESA,6=Pie
input_profile2 = P12_Phantom_Profile.data ! Path to input profile
isoftcore2 = 0 ! 0=no core softening, 1=cubic, 2=const. entropy
isinkcore2 = F ! Add a sink particle stellar core

Notice that you do not get to set the particle resolution for the second star,
since the mass of the particles is fixed by the mass and particle number in star 1.

Replacing dense stellar cores with sink particles
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In the options above you have the option to remove the dense core of the star
which causes small timesteps in the code, and replace it with a softened point
mass. The default option for this is isoftcore1=2 and isinkcore1=1.

For more details, see :doc:`<softstar>`


to start simulation. If anybody reads this, just note that the above
changes to binary.in were made without any REAL knowledge of how this
might affect the end result. Do not try this at home.
Using SETUP=star and moddump_binary
------------------------------------
See :doc:`<star>` for the older two-step procedure. The options available are
identical, but with a bit more flexibility and without
having to re-run the relaxation procedure over and over again.
9 changes: 8 additions & 1 deletion docs/eos-list.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
+-----------+----------------------------------------------------------------------------------+
| ieos | Description |
| ieos | Description |
+===========+==================================================================================+
| 1 | **Isothermal eos** |
| | |
Expand Down Expand Up @@ -92,6 +92,13 @@
| | hence in this equation of state gamma (and temperature) are an output |
| | |
+-----------+----------------------------------------------------------------------------------+
| 13 | **Locally isothermal eos for generic hierarchical system** |
| | |
| | Assuming all sink particles are stars. |
| | Generalisation of Farris et al. (2014; for binaries) to N stars. |
| | For two sink particles this is identical to ieos=14 |
| | |
+-----------+----------------------------------------------------------------------------------+
| 14 | **Locally isothermal eos from Farris et al. (2014) for binary system** |
| | |
| | uses the locations of the first two sink particles |
Expand Down
2 changes: 1 addition & 1 deletion docs/scripts/print_setups.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ print_setup()
printf "+\n"
}
if [ "$1" == "best" ]; then
listofsetups='disc star jet turb cluster'
listofsetups='disc star binary wind jet turb cluster'
else
listofsetups=`grep 'ifeq ($(SETUP)' $phantomdir/build/Makefile_setups | grep -v skip | cut -d, -f 2 | cut -d')' -f 1 | sort`
fi
Expand Down
4 changes: 4 additions & 0 deletions docs/setups-best.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
+------------------+---------------------------------------------------------------+----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------+
| star | import stellar model from 1D stellar evolution code | self-gravity | `setup_star.f90 <https://github.com/danieljprice/phantom/blob/master//src/setup/setup_star.f90>`__ |
+------------------+---------------------------------------------------------------+----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------+
| binary | binary stars | self-gravity | `setup_binary.f90 <https://github.com/danieljprice/phantom/blob/master//src/setup/setup_binary.f90>`__ |
+------------------+---------------------------------------------------------------+----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------+
| wind | wind setup with dust nucleation | | `setup_wind.F90 <https://github.com/danieljprice/phantom/blob/master//src/setup/setup_wind.F90>`__ |
+------------------+---------------------------------------------------------------+----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------+
| jet | Jet simulation from Price, Tricco & Bate (2012) | MHD, self-gravity, isothermal, periodic | `setup_sphereinbox.f90 <https://github.com/danieljprice/phantom/blob/master//src/setup/setup_sphereinbox.f90>`__ |
+------------------+---------------------------------------------------------------+----------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------+
| turb | driven supersonic turbulence (hydro, mhd, dusty) | isothermal | `setup_turb.f90 <https://github.com/danieljprice/phantom/blob/master//src/setup/setup_turb.f90>`__ |
Expand Down

0 comments on commit f80548b

Please sign in to comment.