Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Update sas_gen.py #2617

Merged
merged 2 commits into from
Sep 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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