Skip to content

Commit

Permalink
Merge pull request #2617 from SasView/Sasgen-Fix
Browse files Browse the repository at this point in the history
Update sas_gen.py
  • Loading branch information
krzywon authored Sep 20, 2023
2 parents 2433aa5 + 6029972 commit 22fe701
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions src/sas/sascalc/calculator/sas_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -1192,6 +1192,7 @@ def read(self, path):
x_lines = []
y_lines = []
z_lines = []
atom_value_dict = {}
try:
input_f = open(path, 'rb')
buff = decode(input_f.read())
Expand Down Expand Up @@ -1222,14 +1223,20 @@ def read(self, path):
pos_y.append(_pos_y)
pos_z.append(_pos_z)
try:
val = nsf.neutron_sld(atom_name)[0]
# sld in Ang^-2 unit
val *= 1.0e-6
sld_n.append(val)
atom = formula(atom_name)
# cm to A units
vol = 1.0e+24 * atom.mass / atom.density / NA
vol_pix.append(vol)
if atom_name in atom_value_dict:
sld_n.append(atom_value_dict[atom_name][0])
vol_pix.append(atom_value_dict[atom_name][1])
else:
val = nsf.neutron_sld(atom_name)[0]
# sld in Ang^-2 unit
val *= 1.0e-6
sld_n.append(val)
atom = formula(atom_name)
# # cm to A units
vol = 1.0e+24 * atom.mass / atom.density / NA
vol_pix.append(vol)
atom_value_dict[atom_name] = [val, vol]

except Exception:
logging.warning("Warning: set the sld of %s to zero"% atom_name)
sld_n.append(0.0)
Expand Down

0 comments on commit 22fe701

Please # to comment.