Tue, 06 Oct 2026 00:47:42 -0500
README updates
|
3
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
1 | # |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
2 | # Laser and mirrors convection-diffusion experiment with known diffusivity and convectivity. |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
3 | # Alternative parametrisation |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
4 | # |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
5 | import laser_and_mirrors_aux |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
6 | import numpy as np |
| 12 | 7 | from laser_and_mirrors_aux import generic_setup, reg_params |
|
3
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
8 | from measures import DiscreteMeasure_2_f64 |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
9 | from pointsource_pde import Problem, RegTerm |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
10 | from pointsource_pde.convection_diffusion import BoxedQuadraticRegularisation |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
11 | |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
12 | # Give name to the problem |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
13 | name = "laser_and_mirrors_aux2" |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
14 | |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
15 | # Override algorithm settings |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
16 | algorithm_overrides = laser_and_mirrors_aux.algorithm_overrides |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
17 | |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
18 | |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
19 | # Setup the problem |
| 12 | 20 | def setup( |
| 21 | prefix, | |
| 22 | alpha=reg_params["alpha"], | |
| 23 | alpha_k=reg_params["alpha_k"], | |
| 24 | alpha_c=reg_params["alpha_c"], | |
| 25 | c_noise=reg_params["c_noise"], | |
| 26 | k_noise=reg_params["k_noise"], | |
| 27 | noise=reg_params["noise"], | |
| 28 | seed=reg_params["seed"], | |
| 29 | sim_oversample=reg_params["sim_oversample"], | |
| 30 | sim_oversample_time=reg_params["sim_oversample_time"], | |
| 31 | true_init=False, | |
| 32 | true_target=False, | |
| 33 | scale_cstep=reg_params["scale_cstep"], | |
| 34 | ): | |
| 35 | rng = np.random.default_rng(seed=seed) | |
|
3
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
36 | |
| 12 | 37 | dat, auxtrue, aux0, _μ_bound, μ_true, plot_factory, pde = generic_setup( |
|
3
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
38 | prefix, |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
39 | rng=rng, |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
40 | μ_true=DiscreteMeasure_2_f64([([0.2, 0.3], 0.15), ([0.4, 0.1], 0.04)]), |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
41 | k=0.02, |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
42 | r=0.1, |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
43 | θ=120 * np.pi / 180, |
| 12 | 44 | c_noise=c_noise, |
| 45 | k_noise=k_noise, | |
| 46 | noise=noise, | |
| 47 | sim_oversample=sim_oversample, | |
| 48 | sim_oversample_time=sim_oversample_time, | |
| 49 | scale_cstep=scale_cstep, | |
|
3
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
50 | ) |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
51 | |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
52 | # Override Lipschitz parameter |
| 12 | 53 | dat.override_lipschitz = 1.0 |
| 54 | dat.override_lipschitz_pair = (0.0, 0.0) | |
|
3
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
55 | # print("diff_chain_lipschitz_factor (modified)", pde.diff_chain_lipschitz_factor()) |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
56 | # l1, l2 = pde.diff_chain_lipschitz_factor_pair() |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
57 | # print("diff_chain_lipschitz_factor_pair (modified) ", l1, ", ", l2) |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
58 | |
| 12 | 59 | reg = RegTerm.NonnegRadon(alpha) |
|
3
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
60 | |
|
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
61 | μ0 = DiscreteMeasure_2_f64([]) |
| 12 | 62 | |
| 63 | print("aux init ", aux0) | |
| 64 | aux = BoxedQuadraticRegularisation( | |
| 65 | (0.001, -1.0), | |
| 66 | (1.0, 1.0), | |
| 67 | (alpha_k, alpha_c), | |
| 68 | auxtrue if true_target else aux0, | |
| 69 | (1, scale_cstep) if scale_cstep is not None else None, | |
|
3
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
70 | ) |
| 12 | 71 | print("Initial value:", dat.apply((μ0, aux0)) + aux.apply(aux0)) |
| 72 | print("Value at true μ:", dat.apply((μ_true, auxtrue)) + aux.apply(auxtrue)) | |
|
3
c3a4f4bb87f7
Dolfin update, fixes, additional experiment, build instructions.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff
changeset
|
73 | |
| 12 | 74 | return Problem( |
| 75 | dat, | |
| 76 | reg, | |
| 77 | aux, | |
| 78 | auxtrue if true_init else aux0, | |
| 79 | μ0, | |
| 80 | plot_factory=plot_factory, | |
| 81 | domain=pde.domain_dims, | |
| 82 | ) |