Skip to content

Commit b5848a6

Browse files
committed
Merge main
2 parents 6ff3aa2 + 8b093f6 commit b5848a6

3 files changed

Lines changed: 25 additions & 28 deletions

File tree

blobmodel/model.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,11 +337,12 @@ def _compute_start_stop(self, blob: Blob, speed_up: bool, error: float):
337337
np.abs(blob.t_init * blob.v_x)
338338
+ blob.width_p * np.log(error * np.sqrt(np.pi))
339339
+ blob.pos_x
340-
- self._geometry.t[0]
340+
- self._geometry.t[0] * blob.v_x
341341
)
342342
/ np.abs(self._geometry.dt * blob.v_x)
343343
),
344344
)
345+
start = np.minimum(self._geometry.t.size, start)
345346
# ignores t_drain when calculating stop time
346347
stop = np.minimum(
347348
self._geometry.t.size,

examples/compare_to_analytical_sol.py

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,38 +12,34 @@
1212
# with analytically derived results. See O. E. Garcia, et al.; Phys. Plasmas 1 May 2016; 23 (5): 052308. https://doi.org/10.1063/1.4951016
1313

1414
# use DefaultBlobFactory to define distribution functions fo random variables
15-
bf = DefaultBlobFactory(A_dist=DistributionEnum.deg, vy_dist=DistributionEnum.zeros)
15+
bf = DefaultBlobFactory(
16+
A_dist=DistributionEnum.deg, vy_dist=DistributionEnum.zeros, vy_parameter=10
17+
)
18+
t_drain = 1e10
1619

1720
tmp = Model(
18-
Nx=20,
19-
Ny=1,
21+
Nx=10,
22+
Ny=10,
2023
Lx=10,
21-
Ly=0,
22-
dt=1,
23-
T=1000,
24-
blob_shape=BlobShapeImpl(BlobShapeEnum.exp, BlobShapeEnum.gaussian),
25-
t_drain=2,
26-
periodic_y=False,
24+
Ly=10,
25+
dt=0.1,
26+
T=10000,
27+
blob_shape=BlobShapeImpl(BlobShapeEnum.gaussian, BlobShapeEnum.gaussian),
28+
t_drain=1e10,
29+
periodic_y=True,
2730
num_blobs=10000,
2831
blob_factory=bf,
29-
one_dimensional=True,
32+
one_dimensional=False,
33+
t_init=10,
3034
)
3135

3236
ds = tmp.make_realization(speed_up=True, error=1e-10)
33-
x = np.linspace(0, 10, 20)
34-
t_p = 1
35-
t_w = 1 / 10
36-
amp = 1
37-
v_p = 1.0
38-
t_loss = 2.0
39-
t_d = t_loss * t_p / (t_loss + t_p)
40-
41-
analytical_profile = t_d / t_w * amp * np.exp(-x / (v_p * t_loss))
42-
43-
ds.n.isel(y=0).mean(dim=("t")).plot(label="blob_model")
44-
plt.yscale("log")
45-
plt.xlabel("x")
46-
plt.ylabel("Time average")
47-
plt.plot(x, analytical_profile, label="analytical solution")
48-
plt.legend()
37+
38+
mean = ds.n.mean(dim="t").values
39+
40+
fig, ax = plt.subplots()
41+
42+
im = ax.imshow(mean, clim=(0, np.max(mean)))
43+
plt.colorbar(im, ax=ax)
44+
4945
plt.show()

examples/point_process.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414

1515
dt = 0.1
16-
T = int(1e5)
16+
T = int(1e4)
1717
num_blobs = int(1e5)
1818
start_index = int(100 / dt)
1919

0 commit comments

Comments
 (0)