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

xrb spherical problem setup #2972

Merged
merged 32 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
3ff0599
initial xrb spherical problem setup
zhichen3 Oct 7, 2024
a18761d
update inputfile
zhichen3 Oct 7, 2024
a7ce238
update
zhichen3 Oct 7, 2024
6842f31
update gnumake
zhichen3 Oct 7, 2024
457688c
update
zhichen3 Oct 7, 2024
4169303
chnage input file
zhichen3 Oct 8, 2024
4eb1821
Merge branch 'development' into 2d_spherical_test
zhichen3 Oct 8, 2024
d672904
update input file
zhichen3 Oct 9, 2024
7f21766
add a slice plot script
zhichen3 Oct 10, 2024
934042e
use pslope
zhichen3 Oct 11, 2024
7dca9c5
fix
zhichen3 Oct 11, 2024
0a1cfb0
update script
zhichen3 Oct 12, 2024
3577b58
Merge branch 'development' into 2d_spherical_test
zingale Oct 14, 2024
d68885a
update script
zhichen3 Oct 14, 2024
c99bde8
update
zhichen3 Oct 15, 2024
eecbdf5
fix spelling
zhichen3 Oct 15, 2024
3c63920
update colorbar limit
zhichen3 Oct 15, 2024
15ed991
add README
zhichen3 Oct 16, 2024
321fd68
update script
zhichen3 Oct 16, 2024
a34e135
Merge branch 'development' into 2d_spherical_test
zhichen3 Oct 23, 2024
4f48b03
Merge branch 'development' into 2d_spherical_test
zingale Oct 24, 2024
8eb00d6
update input
zhichen3 Oct 24, 2024
4337b0d
fix boundary condition in input
zhichen3 Oct 24, 2024
e155b99
add 1 r-profile plot at given theta
zhichen3 Oct 24, 2024
4ddef2c
update script
zhichen3 Oct 24, 2024
7d48637
Merge branch 'development' into 2d_spherical_test
zhichen3 Oct 27, 2024
1d5ff06
update script
zhichen3 Oct 29, 2024
5a13fc5
add comment about making sliceplots
zhichen3 Oct 29, 2024
4f53b47
update script
zhichen3 Oct 30, 2024
96a07fa
update makefile
zhichen3 Nov 13, 2024
c1723e1
Merge branch '2d_spherical_test' of github.com:zhichen3/Castro into 2…
zhichen3 Nov 13, 2024
818c166
Merge branch 'development' into 2d_spherical_test
zhichen3 Nov 13, 2024
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
40 changes: 40 additions & 0 deletions Exec/science/xrb_spherical/GNUmakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
PRECISION = DOUBLE
PROFILE = FALSE

DEBUG = FALSE

DIM = 2

COMP = gnu

USE_MPI = TRUE

USE_GRAV = TRUE
USE_REACT = FALSE

USE_ROTATION = FALSE
USE_DIFFUSION = FALSE

# define the location of the CASTRO top directory
CASTRO_HOME ?= ../../..

USE_JACOBIAN_CACHING = TRUE
USE_MODEL_PARSER = TRUE
NUM_MODELS := 2

# This sets the EOS directory in $(MICROPHYSICS_HOME)/eos
EOS_DIR := helmholtz

# This sets the network directory in $(MICROPHYSICS_HOME)/networks
NETWORK_DIR := subch_base

INTEGRATOR_DIR := VODE

CONDUCTIVITY_DIR := stellar

PROBLEM_DIR ?= ./

Bpack := $(PROBLEM_DIR)/Make.package
Blocs := $(PROBLEM_DIR)

include $(CASTRO_HOME)/Exec/Make.Castro
2 changes: 2 additions & 0 deletions Exec/science/xrb_spherical/Make.package
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CEXE_headers += initial_model.H

6 changes: 6 additions & 0 deletions Exec/science/xrb_spherical/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# xrb_spherical

This is the full-star XRB flame setup based on flame_wave.
This setup uses a spherical 2D geometry to model XRB flame
on a spherical shell with initial temperature perturbation
on the north pole.
68 changes: 68 additions & 0 deletions Exec/science/xrb_spherical/_prob_params
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@

dtemp real 3.81e8_rt y

theta_half_max real 1.745e-2_rt y

theta_half_width real 4.9e-3_rt y

# cutoff mass fraction of the first species for refinement
X_min real 1.e-4_rt y

# do we dynamically refine based on density? or based on height?
tag_by_density integer 1 y

# used for tagging if tag_by_density = 1
cutoff_density real 500.e0_rt y

# used if we are refining based on height rather than density
refine_height real 3600 y

T_hi real 5.e8_rt y

T_star real 1.e8_rt y

T_lo real 5.e7_rt y

dens_base real 2.e6_rt y

H_star real 500.e0_rt y

atm_delta real 25.e0_rt y

fuel1_name string "helium-4" y

fuel2_name string "" y

fuel3_name string "" y

fuel4_name string "" y

ash1_name string "iron-56" y

ash2_name string "" y

ash3_name string "" y

fuel1_frac real 1.0_rt y

fuel2_frac real 0.0_rt y

fuel3_frac real 0.0_rt y

fuel4_frac real 0.0_rt y

ash1_frac real 1.0_rt y

ash2_frac real 0.0_rt y

ash3_frac real 0.0_rt y

low_density_cutoff real 1.e-4_rt y

smallx real 1.e-10_rt y

r_refine_distance real 1.e30_rt y

max_hse_tagging_level integer 2 y

max_base_tagging_level integer 1 y
56 changes: 56 additions & 0 deletions Exec/science/xrb_spherical/analysis/r_profile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/usr/bin/env python3

# Spherical R profile at different theta

import os
import sys
import yt
import matplotlib.pyplot as plt
import numpy as np
from functools import reduce
import itertools

import matplotlib.ticker as ptick
from yt.frontends.boxlib.api import CastroDataset
from yt.units import cm


plotfile = sys.argv[1]
ds = CastroDataset(plotfile)

rmin = ds.domain_left_edge[0]
rmax = rmin + 5000.0*cm
#rmax = ds.domain_right_edge[0]
print(ds.domain_left_edge[1])
fig, _ax = plt.subplots(2,2)

axes = list(itertools.chain(*_ax))

fig.set_size_inches(7.0, 8.0)

fields = ["Temp", "density", "x_velocity", "y_velocity"]
nice_names = [r"$T$ (K)", r"$\rho$ (g/${cm}^3$)", r"$u$ (cm/s)", r"$v$ (cm/s)"]

# 4 rays at different theta values
thetal = ds.domain_left_edge[1]
thetar = ds.domain_right_edge[1]
thetas = [thetal, 0.25*thetar, 0.5*thetar, 0.75*thetar]

for i, f in enumerate(fields):

for theta in thetas:
# simply go from (rmin, theta) -> (rmax, theta). Doesn't need to convert to physical R-Z
ray = ds.ray((rmin, theta, 0*cm), (rmax, theta, 0*cm))
isrt = np.argsort(ray["t"])
axes[i].plot(ray['r'][isrt], ray[f][isrt], label=r"$\theta$ = {:.4f}".format(float(theta)))

axes[i].set_xlabel(r"$r$ (cm)")
axes[i].set_ylabel(nice_names[i])
axes[i].set_yscale("symlog")

if i == 0:
axes[0].legend(frameon=False, loc="lower left")

#fig.set_size_inches(10.0, 9.0)
plt.tight_layout()
plt.savefig("{}_profiles.png".format(os.path.basename(plotfile)))
94 changes: 94 additions & 0 deletions Exec/science/xrb_spherical/analysis/slice.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
#!/usr/bin/env python3

import sys
import os
import yt
import numpy as np
import matplotlib.pyplot as plt
from yt.frontends.boxlib.api import CastroDataset

from yt.units import cm

"""
Given a plot file and field name, it gives slice plots at the top,
middle, and bottom of the domain (shell).
"""

def slice(fname:str, field:str,
loc: str = "top", width_factor: float = 3.0) -> None:
"""
A slice plot of the dataset for Spherical2D geometry.
Parameter
=======================
fname: plot file name
field: field parameter
loc: location on the domain. {top, mid, bot}
"""

ds = CastroDataset(fname)
currentTime = ds.current_time.in_units("s")
print(f"Current time of this plot file is {currentTime} s")

# Some geometry properties
rr = ds.domain_right_edge[0].in_units("km")
rl = ds.domain_left_edge[0].in_units("km")
dr = rr - rl
r_center = 0.5 * (rr + rl)

thetar = ds.domain_right_edge[1]
thetal = ds.domain_left_edge[1]
dtheta = thetar - thetal
theta_center = 0.5 * (thetar + thetal)

# Domain width of the slice plot
width = width_factor * dr
box_widths = (width, width)

loc = loc.lower()
loc_options = ["top", "mid", "bot"]

if loc not in loc_options:
raise Exception("loc parameter must be top, mid or bot")

# Centers for the Top, Mid and Bot panels
centers = {"top":(r_center*np.sin(thetal)+0.5*width, r_center*np.cos(thetal)),
"mid":(r_center*np.sin(theta_center), r_center*np.cos(theta_center)),
"bot":(r_center*np.sin(thetar)+0.5*width, r_center*np.cos(thetar))}

# Note we can also set center during SlicePlot, however then we would enter in [r_center, theta_center, 0]
# rather than the physical R-Z coordinate if we do it via sp.set_center

sp = yt.SlicePlot(ds, 'phi', field, width=box_widths)
sp.set_center(centers[loc])

sp.set_cmap(field, "viridis")
if field in ["x_velocity", "y_velocity", "z_velocity"]:
sp.set_cmap(field, "coolwarm")
elif field == "Temp":
sp.set_zlim(f, 5.e7, 2.5e9)
sp.set_cmap(f, "magma_r")
elif field == "enuc":
sp.set_zlim(f, 1.e18, 1.e20)
elif field == "density":
sp.set_zlim(f, 1.e-3, 5.e8)

# sp.annotate_text((0.05, 0.05), f"{currentTime.in_cgs():8.5f} s")
sp.save(f"{ds}_{loc}")

if __name__ == "__main__":

if len(sys.argv) < 3:
raise Exception("Please enter parameters in order of: fname field_name width_factor[optional] loc[optional]")

fname = sys.argv[1]
field = sys.argv[2]
loc = "top"
width_factor = 3.0

if len(sys.argv) == 4:
width_factor = float(sys.argv[3])
elif len(sys.argv) > 4:
loc = sys.argv[4]

slice(fname, field, loc=loc, width_factor=width_factor)
1 change: 1 addition & 0 deletions Exec/science/xrb_spherical/initial_model.H
Loading