Skip to content

Commit

Permalink
round to nearest integer for star polymer arms
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Kienzle committed Jan 29, 2025
1 parent 510234f commit 4df12d8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
14 changes: 9 additions & 5 deletions sasmodels/models/star_polymer.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ double form_volume(void);

double Iq(double q, double radius2, double arms);

static double star_polymer_kernel(double q, double radius2, double arms)
static double star_polymer_kernel(double q, double radius2, int n_arms)
{

double u_2 = radius2 * q * q;
double v = u_2 * arms / (3.0 * arms - 2.0);
double v = (u_2 * n_arms) / (3 * n_arms - 2);

double term1 = v + expm1(-v);
double term2 = ((arms - 1.0)/2.0) * square(expm1(-v));
double term2 = ((n_arms - 1) * square(expm1(-v)))/2.0;

return (2.0 * (term1 + term2)) / (arms * v * v);
return (2.0 * (term1 + term2)) / (n_arms * v * v);

}

Expand All @@ -22,5 +22,9 @@ double form_volume(void)

double Iq(double q, double radius2, double arms)
{
return star_polymer_kernel(q, radius2, arms);
// TODO: round or truncate?
// rounding: stacked_disk pearl_necklace multilayer_vesicle linear_pearls
// lamellar_stack_caille lamellar_hg_stack_caille
// truncation: lamellar_stack_paracrystal
return star_polymer_kernel(q, radius2, int(arms + 0.5));
}
2 changes: 1 addition & 1 deletion sasmodels/models/star_polymer.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
# pylint: disable=bad-whitespace, line-too-long
# ["name", "units", default, [lower, upper], "type","description"],
parameters = [["rg_squared", "Ang^2", 100.0, [0.0, inf], "", "Ensemble radius of gyration SQUARED of the full polymer"],
["arms", "", 3, [1.0, 6.0], "", "Number of arms in the model"],
["arms", "", 3, [1.0, 6.0], "", "Number of arms in the model (integer)"],
]
# pylint: enable=bad-whitespace, line-too-long

Expand Down

0 comments on commit 4df12d8

Please sign in to comment.