added a test case for solving equation with spherical harmonics
@@ -227,6 +227,8 @@ def test_electric_potential_uniformly_charged_ball():
def test_electric_potential_gaussian_charged_density():
+ def subtest(net=None, max_epoch=500):
+ print(f'subtest: network = {net}, max_epoch={max_epoch}')
# total charge
Q = 1.
# standard deviation of gaussian
@@ -249,8 +251,9 @@ def test_electric_potential_gaussian_charged_density():
condition = DirichletBVPSpherical(r_0, lambda th, ph: v_0, r_1, lambda th, ph: v_1)
monitor = MonitorSpherical(r_0, r_1, check_every=50)
- solution, loss_history, analytic_mse = solve_spherical(pde, condition, r_0, r_1, max_epochs=500, return_best=True,
- analytic_solution=analytic_solution, monitor=monitor)
+ solution, loss_history, analytic_mse = solve_spherical(pde, condition, r_0, r_1, max_epochs=max_epoch, net=net,
+ return_best=True, analytic_solution=analytic_solution,
+ monitor=monitor, batch_size=16)
generator = ExampleGeneratorSpherical(512, r_min=r_0, r_max=r_1)
rs, thetas, phis = generator.get_examples()
@@ -260,7 +263,10 @@ def test_electric_potential_gaussian_charged_density():
assert np.isclose(us, vs, rtol=0.05).all(), \
f"Solution doesn't match analytic expectattion {us} != {vs}, relative-diff={rdiff}"
- print("electric-potential-on-gaussian-charged-density passed")
+ print("subtest electric-potential-on-gaussian-charged-density passed")
+
+ subtest(SphericalHarmonicsNN(max_degree=1), max_epoch=200)
+ subtest(None, max_epoch=500)
def test_spherical_harmonics():
