forked from NanoComp/meep
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Python support for Prisms (NanoComp#345)
* Add python Prism wrapper * Increase tolerance and reuse compare_arrays from tests/mpb.py * Simplify vector assignment * Get new scheme data with fixed size blocks * Revert "Get new scheme data with fixed size blocks" This reverts commit 0203ab4aa1fc164e9f3b747a84e0b97280bbbd70. * height is double * Extend prism out of cell and increase height.
- Loading branch information
1 parent
61f32a7
commit 9254a16
Showing
7 changed files
with
110 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import numpy as np | ||
|
||
|
||
def compare_arrays(test_instance, exp, res, tol=1e-3): | ||
exp_1d = exp.ravel() | ||
res_1d = res.ravel() | ||
|
||
norm_exp = np.linalg.norm(exp_1d) | ||
norm_res = np.linalg.norm(res_1d) | ||
|
||
if norm_exp == 0: | ||
test_instance.assertEqual(norm_res, 0) | ||
else: | ||
diff = np.linalg.norm(res_1d - exp_1d) / norm_exp | ||
test_instance.assertLess(diff, tol) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters