Skip to content
Draft
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
eb089fd
[Ramses][AMR][Global PR] 2:1 refinement check
Akos299 Mar 16, 2026
3d237c3
updates
Akos299 Mar 16, 2026
5de2163
[Ramses][AMR] RefinementHandler modules + first tests
Akos299 Mar 19, 2026
0c00c94
sod and sedov_blast test
Akos299 Mar 20, 2026
566bf58
updates
Akos299 Mar 20, 2026
aa6bc48
updates
Akos299 Mar 30, 2026
7d7b127
riemann_2d_problems tests
Akos299 Mar 30, 2026
cc83d20
riemann_2d_problems tests
Akos299 Apr 1, 2026
9f73d96
riemann_2d_problems tests
Akos299 Apr 1, 2026
f43298b
test
Akos299 Apr 1, 2026
93fabfb
Merge branch 'Shamrock-code:main' into features/all-amr-dev
Akos299 Apr 1, 2026
8294319
updates
Akos299 Apr 1, 2026
c281165
Merge branch 'Shamrock-code:main' into features/all-amr-dev
Akos299 Apr 1, 2026
ad6899f
Merge branch 'features/all-amr-dev' into restore-leo-amr
tdavidcl Apr 1, 2026
6bc504f
Merge pull request #1 from Shamrock-code/restore-leo-amr
Akos299 Apr 1, 2026
fb1b5de
Merge branch 'Shamrock-code:main' into features/all-amr-dev
Akos299 Apr 2, 2026
ab65a88
updates
Akos299 Apr 8, 2026
9bbe1ab
Merge branch 'Shamrock-code:main' into features/all-amr-dev
Akos299 Apr 8, 2026
cdbda6a
clean set up for sod amr test
Akos299 Apr 8, 2026
3807ccf
clean set up for sod amr test
Akos299 Apr 8, 2026
440ff4f
updates
Akos299 Apr 8, 2026
8cb10b7
set up for the 1D interacting blast wave test
Akos299 Apr 8, 2026
be2dae5
updates of 1D intersting blast wave test
Akos299 Apr 9, 2026
f861eb7
Shu-Osher Riemann problem setup
Akos299 Apr 16, 2026
6af042a
logger to track diff in rho primitive and rho attached to fieldref
Akos299 Apr 16, 2026
540c0f2
Merge branch 'Shamrock-code:main' into features/all-amr-dev
Akos299 Apr 16, 2026
f979393
trace of the prim debug
Akos299 Apr 16, 2026
5219386
attempt for conservative interpolation at refinement
Akos299 Apr 16, 2026
66ece68
AXPY node header
Akos299 Apr 17, 2026
90df984
AXPY, AYPX, Hadamard product nodes
Akos299 Apr 17, 2026
57998b5
SpMV node
Akos299 Apr 17, 2026
a06399e
Sum Reduction Node
Akos299 Apr 17, 2026
731cd79
PCG init Node
Akos299 Apr 17, 2026
7f2330f
Jacobi preconditioner
Akos299 Apr 17, 2026
fd1e393
Main Loop of CG node
Akos299 Apr 17, 2026
acfb798
rest of nodes for self grvaity coupling [Ramses-like]. Need refinement
Akos299 Apr 17, 2026
e7a60d4
rest of nodes for self grvaity coupling [Ramses-like]. WIP
Akos299 Apr 17, 2026
f520d02
rest of nodes for self grvaity coupling [Ramses-like]. WIP
Akos299 Apr 18, 2026
f7310fe
Cleaning Main CG loop Node [WIP]
Akos299 Apr 18, 2026
e7fd115
Cleaning Main CG loop Node [WIP]
Akos299 Apr 23, 2026
ee12df2
Merge branch 'main' into features/all-amr-dev
Akos299 Apr 23, 2026
ef273bf
Merge branch 'main' into features/all-amr-dev
tdavidcl May 3, 2026
589a35c
Cleaning Main CG loop Node [WIP]
Akos299 May 4, 2026
d1e9d9f
Set up for spherical collapse [WIP]
Akos299 May 4, 2026
da7f81f
tracking bug when coupling AMR and gravity
Akos299 May 21, 2026
3382f9e
Merge branch 'main' into features/all-amr-dev
Akos299 May 21, 2026
e3df1ed
[WIP] modify gradient computation to take into acount the relative d…
Akos299 May 21, 2026
86e0223
[Iso-collapse test] this is for iso. collapse test.
Akos299 May 27, 2026
213883f
Merge branch 'main' into features/all-amr-dev
Akos299 May 27, 2026
e63b71a
[Iso-collapse test] this is for iso. collapse test.
Akos299 May 27, 2026
abfb306
Merge branch 'Shamrock-code:main' into features/all-amr-dev
Akos299 May 27, 2026
ec04f23
comment call of std lib inside kernels
May 28, 2026
7c9c1c7
[self-gravity] cvg test script.
Akos299 May 29, 2026
7629720
barotrop collapse
Jun 14, 2026
a7c9015
Merge branch 'Shamrock-code:main' into features/all-amr-dev
Akos299 Jun 14, 2026
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
216 changes: 216 additions & 0 deletions examples/TO_MIGRATE/ramses/interacting_blast_wave.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
import os

import matplotlib.pyplot as plt
import numpy as np

import shamrock

# If we use the shamrock executable to run this script instead of the python interpreter,
# we should not initialize the system as the shamrock executable needs to handle specific MPI logic
if not shamrock.sys.is_initialized():
shamrock.change_loglevel(1)
shamrock.sys.init("0:0")


def run_1d_interacting_blast_wave_test(
nblocks,
nxbox,
nybox,
):
timestamps = 20
timestep_lists = [0.010, 0.016, 0.026, 0.028, 0.030, 0.032, 0.034, 0.036, 0.038, 0.040, 0.042]
gamma = 1.4

output_folder = "_to_trash/interacting_blast_wave/"
os.makedirs(output_folder, exist_ok=True)

multx = nxbox
multy = nybox
multz = nybox
sz = 1 << 1
base = nblocks
scale_fact = 1 / (sz * base * multx)

rez_plot = 256
positions_plot = [(x, 0, 0) for x in np.linspace(0, 1, rez_plot).tolist()[:-1]]

ctx = shamrock.Context()
ctx.pdata_layout_new()

model = shamrock.get_Model_Ramses(context=ctx, vector_type="f64_3", grid_repr="i64_3")

cfg = model.gen_default_config()
cfg.set_scale_factor(scale_fact)

cfg.set_eos_gamma(gamma)
cfg.set_Csafe(0.8)
cfg.set_riemann_solver_hllc()
cfg.set_slope_lim_vanleer_sym()
cfg.set_face_time_interpolation(True)
cfg.set_boundary_condition("x", "reflective")
cfg.set_boundary_condition("y", "reflective")
cfg.set_boundary_condition("z", "reflective")

model.set_solver_config(cfg)
model.init_scheduler(int(1e7), 1)
model.make_base_grid((0, 0, 0), (sz, sz, sz), (base * multx, base * multy, base * multz))

x0_l = 0.1
x0_r = 0.9
p0_l = 1000
p0_m = 0.01
p0_r = 100


def rho_map(rmin, rmax):
return 1

def rhovel_map(rmin, rmax):
return (0, 0, 0)

def rhoetot_map(rmin, rmax):
x, y, z = rmin
if x < x0_l:
return p0_l / (gamma - 1.0)
elif x < x0_r:
return p0_m / (gamma - 1.0)
else:
return p0_r / (gamma - 1.0)

model.set_field_value_lambda_f64("rho", rho_map)
model.set_field_value_lambda_f64("rhoetot", rhoetot_map)
model.set_field_value_lambda_f64_3("rhovel", rhovel_map)



def analysis():
results = []
for dt in timestep_lists:
model.evolve_until(dt)
rho_vals = model.render_slice("rho", "f64", positions_plot)
rhov_vals = model.render_slice("rhovel", "f64_3", positions_plot)
rhoetot_vals = model.render_slice("rhoetot", "f64", positions_plot)
vx = np.array(rhov_vals)[:, 0] / np.array(rho_vals)
P = (np.array(rhoetot_vals) - 0.5 * np.array(rho_vals) * vx**2) * (gamma - 1)
e_int = P/((gamma - 1.) * np.array(rho_vals))
results_dic = {
"rho": np.array(rho_vals),
"vx": np.array(vx),
"P": np.array(P),
"e_int":np.array(e_int)
}
results.append(results_dic)

output = np.column_stack((np.array(rho_vals), np.array(vx), np.array(P), np.array(e_int)))
filename= f"data_interacting_blast_wave_reso_{2*base*multx}_at_{dt}.txt"
np.savetxt(os.path.join(output_folder,filename),
output,
fmt=["%.10f", "%.10f", "%.10f", "%.10f"],
header="rho vx P e_int",
)
return results

def plot_results(data):
arr_x = [x[0] for x in positions_plot]
for i, frame in enumerate(data):
fig, axs = plt.subplots(2, 2, figsize=(8, 8), dpi=100, constrained_layout=True)

## density
axs[0,0].set_xlabel("$x$")
axs[0,0].set_ylabel("$\\rho$")
axs[0,0].grid(True, alpha=0.3)
axs[0,0].scatter(arr_x, frame["rho"], label=f"{2*base*multx}", s=10, marker = "*")
axs[0,0].legend(loc=0)

## velocity
axs[0,1].set_xlabel("$x$")
axs[0,1].set_ylabel("$v_\\mathrm{x}$")
axs[0,1].grid(True, alpha=0.3)
axs[0,1].scatter(arr_x, frame["vx"], label=f"{2*base*multx}", s=10, marker ="*" )
axs[0,1].legend(loc=0)


## pressure
axs[1,1].set_xlabel("$x$")
axs[1,1].set_ylabel("$\\mathrm{P}$")
axs[1,1].grid(True, alpha=0.3)
axs[1,1].scatter(arr_x, frame["P"], label=f"{2*base*multx}", s=10, marker ="*" )
axs[1,1].legend(loc=0)

## internal energy
axs[1,0].set_xlabel("$x$")
axs[1,0].set_ylabel("$\\mathrm{e}_\\mathrm{int}$")
axs[1,0].grid(True, alpha=0.3)
axs[1,0].scatter(arr_x, frame["e_int"], label=f"{2*base*multx}", s=10, marker ="*" )
axs[1,0].legend(loc=0)

plt.tight_layout()
plt.savefig(os.path.join(output_folder, f"Interacting_blast_wave_test_at_{timestep_lists[i]}_nx_reso_{base*2*multx}.png"))
plt.close(fig)

# def gif_results(data, tmax, case_anim="inter-blast"):

# arr_x = [x[0] for x in positions_plot]

# import matplotlib.animation as animation

# fig2, axs = plt.subplots(2, 2, figsize=(8, 8))
# fig2.suptitle(f"{case_anim} - t = {0.0:.3f} s", fontsize=14)
# ax_rho, ax_vx, ax_P = axs

# # Calculate global min/max across all frames for fixed y-axis limits
# rho_min = min(np.min(frame["rho"]) for frame in data)
# rho_max = max(np.max(frame["rho"]) for frame in data)
# vx_min = min(np.min(frame["vx"]) for frame in data)
# vx_max = max(np.max(frame["vx"]) for frame in data)
# P_min = min(np.min(frame["P"]) for frame in data)
# P_max = max(np.max(frame["P"]) for frame in data)
# eint_min = min(np.min(frame["e_int"]) for frame in data)
# eint_max = max(np.max(frame["e_int"]) for frame in data)

# # Add 5% margin to y-axis limits
# rho_margin = (rho_max - rho_min) * 0.05
# vx_margin = (vx_max - vx_min) * 0.05
# P_margin = (P_max -P_min) * 0.05
# eint_margin = (eint_max - eint_min) * 0.05

# # Configure each axis
# axs[0,0].set_xlabel("$x$")
# axs[0,0].set_ylabel("$\\rho$")
# axs[0,0].set_ylim(rho_min - rho_margin, rho_max + rho_margin)
# axs[0,0].grid(True, alpha=0.3)

# axs[0,1].set_xlabel("$x$")
# axs[0,1].set_ylabel("$v_\\mathrm{x}$")
# axs[0,1].set_ylim(vx_min - vx_margin, vx_max + vx_margin)
# axs[0,1].grid(True, alpha=0.3)


# (line_rho,) = axs[0,0].plot(arr_x, data[0], label="$\\rho$", linewidth=2, color="C0")
# axs[0,0].legend()

# def animate(frame):
# t = tmax * frame / timestamps
# line_rho.set_ydata(data[frame])

# fig2.suptitle(f"{case_anim} - t = {t:.3f} s", fontsize=14)
# return (line_rho, 0)

# anim = animation.FuncAnimation(
# fig2, animate, frames=timestamps + 1, interval=50, blit=False, repeat=True
# )
# plt.tight_layout()
# writer = animation.PillowWriter(fps=15, metadata=dict(artist="Me"), bitrate=1800)
# anim.save(os.path.join(output_folder, "Interacting_blast_wave_test.gif"), writer=writer)
# return anim

def run_and_plot():

data = analysis()

return plot_results(data)

plot = run_and_plot()


run_1d_interacting_blast_wave_test(8, 2<<2, 1)
Loading
Loading