Skip to content

Commit

Permalink
my last commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Sworzzy committed Sep 24, 2024
1 parent 7238ba5 commit eb54321
Show file tree
Hide file tree
Showing 13 changed files with 83 additions and 124 deletions.
2 changes: 1 addition & 1 deletion psydac/api/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,4 @@
'pyccel-intel' : PSYDAC_BACKEND_IPYCCEL,
'pyccel-pgi' : PSYDAC_BACKEND_PGPYCCEL,
'pyccel-nvidia': PSYDAC_BACKEND_NVPYCCEL,
}
}
8 changes: 4 additions & 4 deletions psydac/api/tests/test_2d_complex.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,12 +422,12 @@ def test_complex_helmholtz_2d(plot_sol=False):

print(f'errors: l2 = {l2_error}, h1 = {h1_error}')
print('expected errors: l2 = {}, h1 = {}'.format(expected_l2_error, expected_h1_error))

if plot_sol:
from psydac.feec.multipatch.plotting_utilities import get_plotting_grid, get_grid_vals
from psydac.feec.multipatch.plotting_utilities import get_patch_knots_gridlines, my_small_plot
from psydac.feec.pull_push import pull_2d_h1

Id_mapping = IdentityMapping('M', 2)
# print(f'domain.interior = {domain.interior}')
# domain_interior = [domain]
Expand All @@ -446,7 +446,7 @@ def test_complex_helmholtz_2d(plot_sol=False):
u_vals = grid_vals_h1(u_log)

u_err = [(u1 - u2) for u1, u2 in zip(u_vals, uh_vals)]

my_small_plot(
title=r'approximation of solution $u$',
vals=[u_vals, uh_vals, u_err],
Expand Down Expand Up @@ -538,7 +538,7 @@ def teardown_function():
from psydac.feec.multipatch.plotting_utilities import get_patch_knots_gridlines, my_small_plot
from psydac.api.tests.build_domain import build_pretzel
from psydac.feec.pull_push import pull_2d_hcurl

domain = build_pretzel()
x,y = domain.coordinates

Expand Down
2 changes: 1 addition & 1 deletion psydac/api/tests/test_2d_mapping_poisson.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def run_poisson_2d(filename, solution, f, dir_zero_boundary,
# Compute error norms
l2_error = l2norm_h.assemble(u=uh)
h1_error = h1norm_h.assemble(u=uh)

return l2_error, h1_error

###############################################################################
Expand Down
6 changes: 3 additions & 3 deletions psydac/api/tests/test_2d_multipatch_mapping_maxwell.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from sympde.topology import Square, Domain
from sympde.topology import PolarMapping, LogicalExpr
from sympde.expr.evaluation import TerminalExpr
from sympde.expr.expr import LinearForm, BilinearForm
from sympde.expr.expr import LinearForm, BilinearForm
from sympde.expr.expr import integral
from sympde.expr.expr import Norm
from sympde.expr.equation import find, EssentialBC
Expand Down Expand Up @@ -94,7 +94,7 @@ def run_maxwell_2d(uex, f, alpha, domain, *, ncells=None, degree=None, filename=

equation_h = discretize(equation, domain_h, [Vh, Vh], backend=PSYDAC_BACKEND_GPYCCEL )
l2norm_h = discretize(l2norm, domain_h, Vh, backend=PSYDAC_BACKEND_GPYCCEL)

# Explicitly assemble the linear system
equation_h.assemble()

Expand Down Expand Up @@ -171,7 +171,7 @@ def test_maxwell_2d_2_patch_dirichlet_2():
domain = Domain.from_file(filename)
x,y = domain.coordinates

omega = 1.5
omega = 1.5
alpha = -omega**2
Eex = Tuple(sin(pi*y), sin(pi*x)*cos(pi*y))
f = Tuple(alpha*sin(pi*y) - pi**2*sin(pi*y)*cos(pi*x) + pi**2*sin(pi*y),
Expand Down
6 changes: 3 additions & 3 deletions psydac/api/tests/test_api_2d_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ def run_non_linear_poisson(filename, comm=None):
@pytest.mark.parametrize('axis', [0, 1])
@pytest.mark.parametrize('ext', [-1, 1])
def test_boundary_field_identity(n1, axis, ext):

domain = Square('domain', bounds1=(0., 0.5), bounds2=(0., 1.))
boundary = domain.get_boundary(axis=axis, ext=ext)

Expand All @@ -276,7 +276,7 @@ def test_boundary_field_identity(n1, axis, ext):
assert rel_error_BilinearForm_grad < TOL
assert rel_error_LinearForm < TOL
assert rel_error_LinearForm_grad < TOL

print('PASSED')

def test_field_identity_1():
Expand Down Expand Up @@ -361,4 +361,4 @@ def teardown_function():
if __name__ == '__main__':

print('Running a test...')
test_boundary_field_identity(10, 0, -1)
test_boundary_field_identity(10, 0, -1)
58 changes: 28 additions & 30 deletions psydac/api/tests/test_api_feec_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,33 +170,33 @@ def plot_field_and_error(name, x, y, field_h, field_ex, *gridlines):

def update_plot(fig, t, x, y, field_h, field_ex):
ax0, ax1, cax0, cax1 = fig.axes

# Remove collections from ax0
while ax0.collections:
ax0.collections[0].remove()

# Remove collections from ax1
while ax1.collections:
ax1.collections[0].remove()

# Clear colorbars
while cax0.collections:
cax0.collections[0].remove()

while cax1.collections:
cax1.collections[0].remove()

# Create new contour plots
im0 = ax0.contourf(x, y, field_h)
im1 = ax1.contourf(x, y, field_ex - field_h)

# Create new colorbars
fig.colorbar(im0, cax=cax0)
fig.colorbar(im1, cax=cax1)

# Update the title
fig.suptitle('Time t = {:10.3e}'.format(t))

# Draw the updated plot
fig.canvas.draw()

Expand All @@ -217,17 +217,17 @@ def run_maxwell_2d_TE(*, use_spline_mapping,

from sympde.topology import Domain
from sympde.topology import Square

from sympde.topology import CollelaMapping2D, BaseAnalyticMapping

from sympde.topology import Derham
from sympde.topology import elements_of
from sympde.topology import NormalVector
from sympde.calculus import dot, cross
from sympde.expr import integral
from sympde.expr import BilinearForm

from psydac.api.discretization import discretize
from psydac.api.discretization import discretize
from psydac.api.settings import PSYDAC_BACKENDS
from psydac.feec.pull_push import push_2d_hcurl, push_2d_l2
from psydac.linalg.solvers import inverse
Expand Down Expand Up @@ -305,17 +305,17 @@ def run_maxwell_2d_TE(*, use_spline_mapping,
if use_spline_mapping:
domain_h = discretize(domain, filename=filename, comm=MPI.COMM_WORLD)
derham_h = discretize(derham, domain_h, multiplicity = [mult, mult])

# TO FIX : the way domain.from_file and discretize_domain runs make that only domain_h.domain.interior has an actual SplineMapping. The rest are BaseMapping.
# The trick is to now when to set exactly the BaseMapping to the SplineMapping. We could try in discretize_derham, but see if it doesn't generate any issues for other tests.
mappings=list(domain_h.mappings.values())

if(len(mappings)>1):
raise TypeError("we are not doing multipatch here")

mapping = mappings[0] # mapping is SplineMapping now
derham_h.mapping=mapping

periodic_list = mapping.space.periodic
degree_list = mapping.space.degree

Expand Down Expand Up @@ -490,13 +490,11 @@ def discrete_energies(self, e, b):

# Electric field, x component
fig2 = plot_field_and_error(r'E^x', x, y, Ex_values, Ex_ex(0, x, y), *gridlines)
fig2.show()

# Electric field, y component
fig2.show()
# Electric field, y component
fig3 = plot_field_and_error(r'E^y', x, y, Ey_values, Ey_ex(0, x, y), *gridlines)
fig3.show()

# Magnetic field, z component
fig3.show()
# Magnetic field, z component
fig4 = plot_field_and_error(r'B^z', x, y, Bz_values, Bz_ex(0, x, y), *gridlines)
fig4.show()
# ...
Expand Down Expand Up @@ -751,7 +749,7 @@ def test_maxwell_2d_multiplicity():
verbose = False,
mult = 2
)

TOL = 1e-5
ref = dict(error_l2_Ex = 4.350041934920621e-04,
error_l2_Ey = 4.350041934920621e-04,
Expand All @@ -760,7 +758,7 @@ def test_maxwell_2d_multiplicity():
assert abs(namespace['error_l2_Ex'] - ref['error_l2_Ex']) / ref['error_l2_Ex'] <= TOL
assert abs(namespace['error_l2_Ey'] - ref['error_l2_Ey']) / ref['error_l2_Ey'] <= TOL
assert abs(namespace['error_l2_Bz'] - ref['error_l2_Bz']) / ref['error_l2_Bz'] <= TOL

def test_maxwell_2d_periodic_multiplicity():

namespace = run_maxwell_2d_TE(
Expand All @@ -779,7 +777,7 @@ def test_maxwell_2d_periodic_multiplicity():
verbose = False,
mult =2
)

TOL = 1e-6
ref = dict(error_l2_Ex = 1.78557685e-04,
error_l2_Ey = 1.78557685e-04,
Expand All @@ -788,8 +786,8 @@ def test_maxwell_2d_periodic_multiplicity():
assert abs(namespace['error_l2_Ex'] - ref['error_l2_Ex']) / ref['error_l2_Ex'] <= TOL
assert abs(namespace['error_l2_Ey'] - ref['error_l2_Ey']) / ref['error_l2_Ey'] <= TOL
assert abs(namespace['error_l2_Bz'] - ref['error_l2_Bz']) / ref['error_l2_Bz'] <= TOL


def test_maxwell_2d_periodic_multiplicity_equal_deg():

namespace = run_maxwell_2d_TE(
Expand All @@ -808,12 +806,12 @@ def test_maxwell_2d_periodic_multiplicity_equal_deg():
verbose = False,
mult =2
)

TOL = 1e-6
ref = dict(error_l2_Ex = 2.50585008e-02,
error_l2_Ey = 2.50585008e-02,
error_l2_Bz = 1.58438290e-02)

assert abs(namespace['error_l2_Ex'] - ref['error_l2_Ex']) / ref['error_l2_Ex'] <= TOL
assert abs(namespace['error_l2_Ey'] - ref['error_l2_Ey']) / ref['error_l2_Ey'] <= TOL
assert abs(namespace['error_l2_Bz'] - ref['error_l2_Bz']) / ref['error_l2_Bz'] <= TOL
Expand Down Expand Up @@ -1045,7 +1043,7 @@ def test_maxwell_2d_dirichlet_par():

# Run simulation
namespace = run_maxwell_2d_TE(**vars(args))

# Keep matplotlib windows open
import matplotlib.pyplot as plt
plt.show()
plt.show()
Binary file removed psydac/api/tests/test_export_fields_parallel.h5
Binary file not shown.
20 changes: 0 additions & 20 deletions psydac/api/tests/test_export_fields_parallel.yml

This file was deleted.

4 changes: 0 additions & 4 deletions psydac/cad/cad.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ def elevate(mapping, axis, times):
degree algorithm in psydac
"""

raise NotImplementedError('Igakit dependencies commented to support python 3.12. `elevate` must be re-implemented')

try:
from igakit.nurbs import NURBS
except:
Expand Down Expand Up @@ -123,8 +121,6 @@ def refine(mapping, axis, values):
insertion algorithm in psydac
"""

raise NotImplementedError('Igakit dependencies commented to support python 3.12. `refine` must be re-implemented')

try:
from igakit.nurbs import NURBS
except:
Expand Down
Loading

0 comments on commit eb54321

Please sign in to comment.