Skip to content

Commit 9713103

Browse files
committed
adding gifs
1 parent a7f488d commit 9713103

File tree

10 files changed

+22
-10
lines changed

10 files changed

+22
-10
lines changed

adirondax/simulation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ def step_fn_stacked(carry, _):
399399
plot_sim(state, checkpoint_dir, i, self.params)
400400
else:
401401
carry, _ = jax.lax.scan(step_fn_stacked, carry, xs=None, length=nt)
402-
return carry
402+
return carry
403403

404404
# save initial state
405405
if jax.process_index() == 0:
2.4 MB
Loading

examples/logo_inverse_problem/logo_inverse_problem.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"""
2121

2222

23-
def set_up_simulation():
23+
def set_up_simulation(save=False):
2424
# Define the parameters for the simulation
2525
n = 128
2626
nt = 100 * int(n / 128)
@@ -40,6 +40,10 @@ def set_up_simulation():
4040
"span": t_stop,
4141
"num_timesteps": nt,
4242
},
43+
"output": {
44+
"save": save,
45+
"plot_dynamic_range": 2.0,
46+
},
4347
}
4448

4549
# Initialize the simulation
@@ -51,7 +55,7 @@ def set_up_simulation():
5155
def solve_inverse_problem(sim):
5256
# Load the target density field
5357
target_data = img.imread("target.png")[:, :, 0]
54-
rho_target = jnp.flipud(jnp.array(target_data, dtype=float))
58+
rho_target = jnp.flipud(jnp.array(target_data, dtype=float)).T
5559
rho_target = 1.0 - 0.5 * (rho_target - 0.5)
5660
rho_target /= jnp.mean(rho_target)
5761

@@ -100,7 +104,7 @@ def make_plot(psi, theta):
100104
ax2 = plt.subplot(grid[0, 1])
101105
plt.sca(ax1)
102106
plt.cla()
103-
plt.imshow(theta, cmap="bwr")
107+
plt.imshow(theta.T, cmap="bwr")
104108
plt.clim(-jnp.pi, jnp.pi)
105109
ax1.get_xaxis().set_visible(False)
106110
ax1.get_yaxis().set_visible(False)
@@ -109,7 +113,7 @@ def make_plot(psi, theta):
109113
plt.title(r"${\rm initial\,angle}(\psi)$")
110114
plt.sca(ax2)
111115
plt.cla()
112-
plt.imshow(jnp.log10(jnp.abs(psi) ** 2), cmap="inferno")
116+
plt.imshow(jnp.log10(jnp.abs(psi) ** 2).T, cmap="inferno")
113117
plt.clim(-0.2, 0.2)
114118
ax2.get_xaxis().set_visible(False)
115119
ax2.get_yaxis().set_visible(False)
@@ -122,8 +126,9 @@ def make_plot(psi, theta):
122126

123127

124128
def main():
125-
sim = set_up_simulation()
129+
sim = set_up_simulation(save=False)
126130
theta = solve_inverse_problem(sim)
131+
sim = set_up_simulation(save=True)
127132
psi = rerun_simulation(sim, theta)
128133
make_plot(psi, theta)
129134

examples/logo_inverse_problem/logo_inverse_problem_optax.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def continuing_criterion(carry):
102102
def solve_inverse_problem(sim):
103103
# Load the target density field
104104
target_data = img.imread("target.png")[:, :, 0]
105-
rho_target = jnp.flipud(jnp.array(target_data, dtype=float))
105+
rho_target = jnp.flipud(jnp.array(target_data, dtype=float)).T
106106
rho_target = 1.0 - 0.5 * (rho_target - 0.5)
107107
rho_target /= jnp.mean(rho_target)
108108

@@ -151,7 +151,7 @@ def make_plot(psi, theta):
151151
ax2 = plt.subplot(grid[0, 1])
152152
plt.sca(ax1)
153153
plt.cla()
154-
plt.imshow(theta, cmap="bwr")
154+
plt.imshow(theta.T, cmap="bwr")
155155
plt.clim(-jnp.pi, jnp.pi)
156156
ax1.get_xaxis().set_visible(False)
157157
ax1.get_yaxis().set_visible(False)
@@ -160,7 +160,7 @@ def make_plot(psi, theta):
160160
plt.title(r"${\rm initial\,angle}(\psi)$")
161161
plt.sca(ax2)
162162
plt.cla()
163-
plt.imshow(jnp.log10(jnp.abs(psi) ** 2), cmap="inferno")
163+
plt.imshow(jnp.log10(jnp.abs(psi) ** 2).T, cmap="inferno")
164164
plt.clim(-0.2, 0.2)
165165
ax2.get_xaxis().set_visible(False)
166166
ax2.get_yaxis().set_visible(False)
11.7 MB
Loading
5 Bytes
Loading
877 Bytes
Loading

examples/orszag_tang/orszag_tang.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
def set_up_simulation():
2424
# Define the parameters for the simulation
2525
n = 512
26+
nt = -1 # 2400
2627
t_stop = 0.5
2728
gamma = 5.0 / 3.0
2829
box_size = 1.0
@@ -40,6 +41,12 @@ def set_up_simulation():
4041
},
4142
"time": {
4243
"span": t_stop,
44+
"num_timesteps": nt,
45+
},
46+
"output": {
47+
"num_checkpoints": 100,
48+
"save": False,
49+
"plot_dynamic_range": 2.3,
4350
},
4451
"hydro": {
4552
"eos": {"type": "ideal", "gamma": gamma},

examples/orszag_tang/output.gif

3.39 MB
Loading

scripts/make_gif.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ if [ -z "$folder" ]; then
1010
exit 1
1111
fi
1212

13-
magick "$folder"/dm*.png "$output"
13+
magick "$folder"/*.png "$output"
1414
echo "GIF created: $output"

0 commit comments

Comments
 (0)