Changeset beb374a in sasview
- Timestamp:
- May 27, 2010 4:16:00 PM (15 years ago)
- Branches:
- master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- d734a3b1
- Parents:
- 2f1a0dc
- Location:
- calculator
- Files:
-
- 34 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
calculator/sld_calculator.py
r89108a0 rbeb374a 1 1 """ 2 This module intends to compute the neutron scattering length density of molecule 3 @author: Gervaise B. Alina 2 This module intends to compute the neutron scattering length density 3 of a molecule. It uses methods of the periodictable package to provide 4 easy user interface for Sld calculator applications. 4 5 """ 5 6 … … 13 14 class SldCalculator(object): 14 15 """ 15 compute neutron SLD and related parameters 16 Given a molecule, a density and a wavelength, this class 17 determine scattering length density. 16 18 """ 17 19 def __init__(self): … … 27 29 def set_value(self, user_formula, density, wavelength=6.0): 28 30 """ 29 Store values of density and wavelength into the calculator30 and compute the volume31 Store values into the sld calculator and compute the corresponding 32 volume. 31 33 """ 32 34 self.wavelength = wavelength … … 37 39 raise ZeroDivisionError("integer division or modulo\ 38 40 by zero for density") 39 return40 41 self.volume = (self.sld_formula.mass / self.density) / avogadro_number\ 41 42 *1.0e24 … … 44 45 def calculate_xray_sld(self, element): 45 46 """ 46 47 47 Get an element and compute the corresponding SLD for a given formula 48 @param element: elementis a string of existing atom 48 49 """ 49 50 myformula = formula(str(element)) … … 61 62 def calculate_neutron_sld(self): 62 63 """ 63 64 65 @return coh: coherence cross section66 64 Compute the neutron SLD for a given molecule 65 @return absorp: absorption 66 return coh: coherence cross section 67 @return inc: incoherence cross section 67 68 """ 68 69 if self.density == 0: … … 75 76 #Don't know if value is return in cm or cm^(-1).assume return in cm 76 77 # to match result of neutron inc of Alan calculator 77 self.incoherence = inc * 1/10 78 #Doesn't match result of Alan calculator for absorption factor of 2 79 #multiplication of 100 is going around 80 self.absorption = absorp * 2 * 100 78 self.incoherence = inc 79 self.absorption = absorp 81 80 self.coherence = coh 82 81 return self.coherence, self.absorption, self.incoherence … … 85 84 def calculate_length(self): 86 85 """ 87 86 Compute the neutron 1/e length 88 87 """ 89 88 self.length = (self.coherence + self.absorption +\ … … 94 93 def calculate_coherence_im(self): 95 94 """ 96 95 Compute imaginary part of the absorption 97 96 """ 98 97 atom = self.sld_formula.atoms
Note: See TracChangeset
for help on using the changeset viewer.