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

add spherical geometry support in compressible #204

Merged
merged 79 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from 78 commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
b74c474
initial update
zhichen3 May 2, 2024
b37fbe8
update
zhichen3 May 2, 2024
62432bc
Merge branch 'spherical_polar_grid' of github.com:zhichen3/pyro2 into…
zhichen3 May 15, 2024
62423e1
update
zhichen3 May 20, 2024
829d164
make advection interface more readable
zhichen3 May 29, 2024
4f2d04e
revert advection files
zhichen3 Jul 12, 2024
4ba2390
Merge branch 'main' into spherical_polar_grid
zhichen3 Jul 12, 2024
d501d70
fix flake8
zhichen3 Jul 12, 2024
11f26d6
update example
zhichen3 Jul 12, 2024
c9a084b
use ArrayIndexer for area and volume
zhichen3 Jul 14, 2024
8f26cb1
fix flake8
zhichen3 Jul 14, 2024
c823b37
add unit test to cartesian2d and spherical polar
zhichen3 Jul 16, 2024
c921ebb
add __str__ and update mesh-example to demonstrate sphericalPolar gri…
zhichen3 Jul 16, 2024
2174795
fix flake8
zhichen3 Jul 16, 2024
c0e9164
fix pytest
zhichen3 Jul 16, 2024
1de6124
update notebook
zhichen3 Jul 16, 2024
b93c187
add left and right area
zhichen3 Jul 20, 2024
c246e8a
Merge branch 'main' into spherical_polar_grid
zhichen3 Jul 20, 2024
1bdecc7
update conservative update
zhichen3 Jul 20, 2024
1dab7ae
change x2d y2d to arrayindexer
zhichen3 Jul 20, 2024
1ebe1ad
remove unused variable
zhichen3 Jul 20, 2024
e272347
Merge branch 'compressible_geometric_term' of github.com:zhichen3/pyr…
zhichen3 Jul 21, 2024
acc3a30
fix dtdV
zhichen3 Jul 21, 2024
bb91e21
add differential length of each direction
zhichen3 Jul 24, 2024
0428bbe
Merge branch 'spherical_polar_grid' into compressible_geometric_term
zhichen3 Jul 24, 2024
372bd63
update with spherical polar source terms
zhichen3 Jul 24, 2024
9ff7e64
more update
zhichen3 Jul 25, 2024
5175260
Merge branch 'compressible_geometric_term' of github.com:zhichen3/pyr…
zhichen3 Jul 25, 2024
5731d07
fix flake8
zhichen3 Jul 25, 2024
eacef13
fix isort
zhichen3 Jul 25, 2024
e6b1e00
revert interface.state back to old interface
zhichen3 Jul 25, 2024
43db316
change Lx and Ly to 1d array or float
zhichen3 Jul 25, 2024
815890b
Merge branch 'spherical_polar_grid' into compressible_geometric_term
zhichen3 Jul 25, 2024
e40a8a5
update BC with dens_src and xmom_src
zhichen3 Jul 25, 2024
0151d78
revert
zhichen3 Jul 25, 2024
49a224b
Merge branch 'spherical_polar_grid' into compressible_geometric_term
zhichen3 Jul 25, 2024
083ce8d
fix dtdx and dtdy indexing
zhichen3 Jul 25, 2024
987b098
update Ly for sphericalpolar
zhichen3 Jul 25, 2024
b409f9d
update np.cot to 1/np.tan also update visualization to be compatibile…
zhichen3 Jul 25, 2024
8c1e92d
fix flake8 and remove comment
zhichen3 Jul 25, 2024
194f7c4
update to use new conservative form, by not grouping pressure inside …
zhichen3 Jul 31, 2024
a6ac3d6
add coord_type to grid class
zhichen3 Jul 31, 2024
b8268d4
Merge branch 'spherical_polar_grid' into compressible_geometric_term
zhichen3 Jul 31, 2024
5b16f4e
update
zhichen3 Jul 31, 2024
3cc217c
update
zhichen3 Jul 31, 2024
6bb2b66
update
zhichen3 Jul 31, 2024
1a6b0d4
fix error message when using HLLC with sphericalpolar geometry
zhichen3 Jul 31, 2024
172f62c
fix flake8
zhichen3 Jul 31, 2024
2bc645b
add try except for getting riemann solver
zhichen3 Aug 1, 2024
0933ee9
update unit_test to specify riemann solver
zhichen3 Aug 1, 2024
3dde81c
specify riemann solver in compressible_rk unit test
zhichen3 Aug 1, 2024
5d6baa1
revert unit tests back and only add warning if riemann solver is not set
zhichen3 Aug 1, 2024
1c491e0
change from isinstance to check coord_type
zhichen3 Aug 1, 2024
32cf030
fix unintentional extra pressure
zhichen3 Aug 1, 2024
95538df
remove old code
zhichen3 Aug 1, 2024
05b58f6
fix flake8 and pylint
zhichen3 Aug 1, 2024
0f1ed3c
get rid of redundant A_r, fix A_y calcualtion for sphericalpolar and …
zhichen3 Aug 1, 2024
e8c4927
Merge branch 'spherical_polar_grid' into compressible_geometric_term
zhichen3 Aug 1, 2024
3db2751
update area factors
zhichen3 Aug 1, 2024
4a13b12
Merge branch 'main' into compressible_geometric_term
zhichen3 Aug 1, 2024
893c670
add a spherical advection problem. temporarily disable aritficial vis…
zhichen3 Aug 1, 2024
b1eaaa8
correct source term
zhichen3 Aug 1, 2024
ffafd72
merge spherical_advect with just advect
zhichen3 Aug 1, 2024
8b4d19e
fix flake8
zhichen3 Aug 1, 2024
ae42ae4
add spherical sedov input
zhichen3 Aug 26, 2024
1db79ab
update artificial viscosity to be in-sync with castro and add spheric…
zhichen3 Aug 27, 2024
fd01f70
add spherical advect with different resolutions for convergence test
zhichen3 Aug 27, 2024
cc349e6
update misc
zhichen3 Aug 27, 2024
f706483
update how to compute timestep
zhichen3 Aug 28, 2024
6ea0272
simplify timestep again
zhichen3 Aug 28, 2024
f39a167
Merge branch 'main' into compressible_geometric_term
zhichen3 Aug 28, 2024
719bbfb
update module
zhichen3 Aug 28, 2024
d4b73dc
update modules
zhichen3 Aug 28, 2024
9f53d16
fix pylint
zhichen3 Aug 28, 2024
ae846c6
update artificial viscosity in compressible_rk
zhichen3 Aug 28, 2024
f761b67
Merge branch 'main' into compressible_geometric_term
zhichen3 Aug 29, 2024
c27e0cd
use apply_artificial_viscosity in compressible_rk and update riemann_…
zhichen3 Aug 30, 2024
c903938
fix flake8
zhichen3 Aug 30, 2024
c8a24f1
add more comments
zhichen3 Aug 30, 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
8 changes: 6 additions & 2 deletions pyro/compressible/BC.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ def user(bc_name, bc_edge, variable, ccdata):

# we will take the density to be constant, the velocity to
# be outflow, and the pressure to be in HSE
if variable in ["density", "x-momentum", "y-momentum", "ymom_src", "E_src", "fuel", "ash"]:
if variable in ["density", "x-momentum", "y-momentum",
"dens_src", "xmom_src", "ymom_src", "E_src",
"fuel", "ash"]:
v = ccdata.get_var(variable)
j = myg.jlo-1
while j >= 0:
Expand Down Expand Up @@ -99,7 +101,9 @@ def user(bc_name, bc_edge, variable, ccdata):

# we will take the density to be constant, the velocity to
# be outflow, and the pressure to be in HSE
if variable in ["density", "x-momentum", "y-momentum", "ymom_src", "E_src", "fuel", "ash"]:
if variable in ["density", "x-momentum", "y-momentum",
"dens_src", "xmom_src", "ymom_src", "E_src",
"fuel", "ash"]:
v = ccdata.get_var(variable)
for j in range(myg.jhi+1, myg.jhi+myg.ng+1):
v[:, j] = v[:, myg.jhi]
Expand Down
21 changes: 11 additions & 10 deletions pyro/compressible/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def states(idir, ng, dx, dt,
Are we predicting to the edges in the x-direction (1) or y-direction (2)?
ng : int
The number of ghost cells
dx : float
dx : ndarray
The cell spacing
dt : float
The timestep
Expand Down Expand Up @@ -133,13 +133,13 @@ def states(idir, ng, dx, dt,
q[irho] / cs, 0.0, 0.5 / (cs * cs)]
lvec[1, :ns] = [1.0, 0.0,
0.0, -1.0 / (cs * cs)]
lvec[2, :ns] = [0.0, 0.0, 1.0, 0.0]
lvec[2, :ns] = [0.0, 0.0, 1.0, 0.0]
lvec[3, :ns] = [0.0, 0.5 *
q[irho] / cs, 0.0, 0.5 / (cs * cs)]

rvec[0, :ns] = [1.0, -cs / q[irho], 0.0, cs * cs]
rvec[1, :ns] = [1.0, 0.0, 0.0, 0.0]
rvec[2, :ns] = [0.0, 0.0, 1.0, 0.0]
rvec[1, :ns] = [1.0, 0.0, 0.0, 0.0]
rvec[2, :ns] = [0.0, 0.0, 1.0, 0.0]
rvec[3, :ns] = [1.0, cs / q[irho], 0.0, cs * cs]

# now the species -- they only have a 1 in their corresponding slot
Expand Down Expand Up @@ -174,29 +174,30 @@ def states(idir, ng, dx, dt,
if idir == 1:
# this is one the right face of the current zone,
# so the fastest moving eigenvalue is e_val[3] = u + c
factor = 0.5 * (1.0 - dtdx * max(e_val[3], 0.0))
factor = 0.5 * (1.0 - dtdx[i, j] * max(e_val[3], 0.0))
q_l[i + 1, j, :] = q + factor * dq

# left face of the current zone, so the fastest moving
# eigenvalue is e_val[3] = u - c
factor = 0.5 * (1.0 + dtdx * min(e_val[0], 0.0))
factor = 0.5 * (1.0 + dtdx[i, j] * min(e_val[0], 0.0))
q_r[i, j, :] = q - factor * dq

else:

factor = 0.5 * (1.0 - dtdx * max(e_val[3], 0.0))
factor = 0.5 * (1.0 - dtdx[i, j] * max(e_val[3], 0.0))
q_l[i, j + 1, :] = q + factor * dq

factor = 0.5 * (1.0 + dtdx * min(e_val[0], 0.0))
factor = 0.5 * (1.0 + dtdx[i, j] * min(e_val[0], 0.0))
q_r[i, j, :] = q - factor * dq

# compute the Vhat functions
for m in range(nvar):
asum = np.dot(lvec[m, :], dq)

betal[m] = dtdx4 * (e_val[3] - e_val[m]) * \
# Should we change to max(e_val[3], 0.0) and min(e_val[0], 0.0)?
betal[m] = dtdx4[i, j] * (e_val[3] - e_val[m]) * \
(np.copysign(1.0, e_val[m]) + 1.0) * asum
betar[m] = dtdx4 * (e_val[0] - e_val[m]) * \
betar[m] = dtdx4[i, j] * (e_val[0] - e_val[m]) * \
(1.0 - np.copysign(1.0, e_val[m])) * asum

# construct the states
Expand Down
38 changes: 30 additions & 8 deletions pyro/compressible/problems/advect.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,38 @@ def init_data(my_data, rp):
ymin = rp.get_param("mesh.ymin")
ymax = rp.get_param("mesh.ymax")

xctr = 0.5*(xmin + xmax)
yctr = 0.5*(ymin + ymax)
myg = my_data.grid

# this is identical to the advection/smooth problem
dens[:, :] = 1.0 + np.exp(-60.0*((my_data.grid.x2d-xctr)**2 +
(my_data.grid.y2d-yctr)**2))
if myg.coord_type == 0:
xctr = 0.5*(xmin + xmax)
yctr = 0.5*(ymin + ymax)

# this is identical to the advection/smooth problem
dens[:, :] = 1.0 + np.exp(-60.0*((my_data.grid.x2d-xctr)**2 +
(my_data.grid.y2d-yctr)**2))

# velocity is diagonal
u = 1.0
v = 1.0

else:
x = myg.scratch_array()
y = myg.scratch_array()

xctr = 0.5*(xmin + xmax) * np.sin((ymin + ymax) * 0.25)
yctr = 0.5*(xmin + xmax) * np.cos((ymin + ymax) * 0.25)

x[:, :] = myg.x2d.v(buf=myg.ng) * np.sin(myg.y2d.v(buf=myg.ng))
y[:, :] = myg.x2d.v(buf=myg.ng) * np.cos(myg.y2d.v(buf=myg.ng))

# this is identical to the advection/smooth problem
dens[:, :] = 1.0 + np.exp(-120.0*((x-xctr)**2 +
(y-yctr)**2))

# velocity in theta direction.
u = 0.0
v = 1.0

# velocity is diagonal
u = 1.0
v = 1.0
xmom[:, :] = dens[:, :]*u
ymom[:, :] = dens[:, :]*v

Expand Down
2 changes: 1 addition & 1 deletion pyro/compressible/problems/inputs.advect.128
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ cvisc = 0.1


[io]
basename = advect_
basename = advect_128_


[eos]
Expand Down
2 changes: 1 addition & 1 deletion pyro/compressible/problems/inputs.advect.256
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ cvisc = 0.1


[io]
basename = advect_
basename = advect_256_


[eos]
Expand Down
2 changes: 1 addition & 1 deletion pyro/compressible/problems/inputs.advect.64
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ cvisc = 0.1


[io]
basename = advect_
basename = advect_64_


[eos]
Expand Down
39 changes: 39 additions & 0 deletions pyro/compressible/problems/inputs.advect.spherical.128
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
[driver]
max_steps = 500
tmax = 1.0

init_tstep_factor = 1.0
fix_dt = 0.0025


[compressible]
limiter = 0
cvisc = 0.1
riemann = CGF

[io]
basename = spherical_advect_128_


[eos]
gamma = 1.4


[mesh]
grid_type = SphericalPolar
nx = 128
ny = 128
xmin = 1.0
xmax = 2.0
ymin = 0.523
ymax = 2.617

xlboundary = outflow
xrboundary = outflow

ylboundary = outflow
yrboundary = outflow


[vis]
dovis = 1
39 changes: 39 additions & 0 deletions pyro/compressible/problems/inputs.advect.spherical.256
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
[driver]
max_steps = 1000
tmax = 1.0

init_tstep_factor = 1.0
fix_dt = 0.00125


[compressible]
limiter = 0
cvisc = 0.1
riemann = CGF

[io]
basename = spherical_advect_256_


[eos]
gamma = 1.4


[mesh]
grid_type = SphericalPolar
nx = 256
ny = 256
xmin = 1.0
xmax = 2.0
ymin = 0.523
ymax = 2.617

xlboundary = outflow
xrboundary = outflow

ylboundary = outflow
yrboundary = outflow


[vis]
dovis = 1
39 changes: 39 additions & 0 deletions pyro/compressible/problems/inputs.advect.spherical.64
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
[driver]
max_steps = 500
tmax = 1.0

init_tstep_factor = 1.0
fix_dt = 0.005


[compressible]
limiter = 0
cvisc = 0.1
riemann = CGF

[io]
basename = spherical_advect_64_


[eos]
gamma = 1.4


[mesh]
grid_type = SphericalPolar
nx = 64
ny = 64
xmin = 1.0
xmax = 2.0
ymin = 0.523
ymax = 2.617

xlboundary = outflow
xrboundary = outflow

ylboundary = outflow
yrboundary = outflow


[vis]
dovis = 1
41 changes: 41 additions & 0 deletions pyro/compressible/problems/inputs.sedov.spherical
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
[driver]
max_steps = 5000
tmax = 0.1


[compressible]
limiter = 2
cvisc = 0.1
riemann = CGF

[io]
basename = sedov_spherical_
dt_out = 0.0125


[eos]
gamma = 1.4


[mesh]
grid_type = SphericalPolar
nx = 128
ny = 128
xmin = 0.1
xmax = 1.0
ymin = 0.785
ymax = 2.355

xlboundary = reflect-odd
xrboundary = outflow

ylboundary = outflow
yrboundary = outflow


[sedov]
r_init = 0.13


[vis]
dovis = 1
Loading