From a25b3ca8b3a0bec493932efd2172690572cacede Mon Sep 17 00:00:00 2001 From: krzywon Date: Thu, 11 Jul 2024 16:22:59 -0400 Subject: [PATCH 1/2] Fix fcc_paracrystal lattice parameter calculation (multiply rather than divide) --- sasmodels/models/fcc_paracrystal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sasmodels/models/fcc_paracrystal.c b/sasmodels/models/fcc_paracrystal.c index 76ef61be..e3f9788e 100644 --- a/sasmodels/models/fcc_paracrystal.c +++ b/sasmodels/models/fcc_paracrystal.c @@ -5,7 +5,7 @@ fcc_Zq(double qa, double qb, double qc, double dnn, double d_factor) const double a1 = ( qa + qb)/2.0; const double a2 = ( qa + qc)/2.0; const double a3 = ( qb + qc)/2.0; - const double d_a = dnn/sqrt(2); + const double d_a = dnn*sqrt(2); // Matsuoka 23-24-25 // Z_k numerator: 1 - exp(a)^2 From a09344ec3aac638f962e4eb2905446b7e183589a Mon Sep 17 00:00:00 2001 From: butlerpd Date: Mon, 15 Jul 2024 22:41:06 +0000 Subject: [PATCH 2/2] Fix unit test for FCC model to match corrected math. Values given by Jonathan Gaudet. Note that more robuts testing would be useful and should be added in the future. --- sasmodels/models/fcc_paracrystal.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sasmodels/models/fcc_paracrystal.py b/sasmodels/models/fcc_paracrystal.py index 35b19b16..b8711cfc 100644 --- a/sasmodels/models/fcc_paracrystal.py +++ b/sasmodels/models/fcc_paracrystal.py @@ -213,9 +213,10 @@ def random(): # # October 26, 2022, PDB fixed unit tests to conform to new maths # TODO: fix the 2d tests -q = 4.*pi/220. +# Test position of first Bragg Peak at q = 2.0 * pi * np.sqrt(3) / (np.sqrt(2) * 220) +q=0.035 tests = [ - [{}, [0.001, q, 0.25], [1.9839734995338474, 0.3352457353010224, 0.005804136688760973]], + [{}, [0.01, q, 0.25], [0.0213498915484313, 69.03586722100925, 0.005713137547083953]], #[{}, (-0.047, -0.007), 238.103096286], #[{}, (0.053, 0.063), 0.863609587796], ]