Skip to content

Commit

Permalink
Check shape (#110)
Browse files Browse the repository at this point in the history
* Check shape of applied field in solve

* Test applied field shape check

* Update version.py

* Update dates in license
  • Loading branch information
loganbvh committed Jan 17, 2024
1 parent 82eb20c commit 928b668
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 4 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021-2023 Logan Bishop-Van Horn
Copyright (c) 2021-2024 Logan Bishop-Van Horn

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion docs/about/license.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ License
MIT License
Copyright (c) 2021-2023 Logan Bishop-Van Horn
Copyright (c) 2021-2024 Logan Bishop-Van Horn
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
8 changes: 7 additions & 1 deletion superscreen/solver/solve.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,10 +405,16 @@ def solve(
layer = device.layers[film_info[film].layer]
z0 = layer.z0 * np.ones(len(mesh.sites))
# Units: current_units / device.length_units
applied_fields[film] = (
Hz_applied = np.squeeze(
applied_field(mesh.sites[:, 0], mesh.sites[:, 1], z0)
* field_conversion.magnitude
).astype(dtype, copy=False)
if Hz_applied.ndim != 1:
raise ValueError(
"Expected applied_field to return a 1D vector,"
f" got a {Hz_applied.shape[1]}D vector."
)
applied_fields[film] = Hz_applied

# Vortex flux in magnetization-like units,
# i.e. H * area as opposed to B * area = mu_0 * H * area.
Expand Down
11 changes: 11 additions & 0 deletions superscreen/test/test_solve.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,3 +325,14 @@ def test_fluxoid_multi(two_rings):
fluxoids[hole_name],
atol=1e-5,
)


def test_applied_field_shape(device: sc.Device):
dipole_field = sc.sources.DipoleField(
dipole_positions=[(0, 0, 1000)],
dipole_moments=[(0, 0, 100000)],
moment_units="uA * um ** 2",
length_units="um",
)
with pytest.raises(ValueError):
_ = sc.solve(device=device, applied_field=dipole_field)
2 changes: 1 addition & 1 deletion superscreen/version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__version_info__ = (0, 10, 5)
__version_info__ = (0, 10, 6)
__version__ = ".".join(map(str, __version_info__))

0 comments on commit 928b668

Please sign in to comment.