Commit 2691968b authored by Remi Perenon's avatar Remi Perenon

Merge branch 'feature-total_structure_factor' into 'develop'

Feature total structure factor

See merge request !42
parents 9d752529 ee25bb7e
Pipeline #4763 passed with stages
in 24 minutes and 33 seconds
* ADDED Neutron Dynamic Total Structure Factor analysis
* FIXED issue #41 Instrument resolution window froze GUI on macOS
* FIXED issue #40 MDANSE could not be used on Ubuntu Bionic systems (due to vtk dependency name)
......
......@@ -138,9 +138,10 @@ class DynamicCoherentStructureFactor(IJob):
#. x (any): The returned result(s) of run_step
"""
for pair in self._elementsPairs:
corr = correlation(x[pair[0]],x[pair[1]], average=1)
self._outputData["f(q,t)_%s%s" % pair][index,:] += corr
if x is not None:
for pair in self._elementsPairs:
corr = correlation(x[pair[0]],x[pair[1]], average=1)
self._outputData["f(q,t)_%s%s" % pair][index,:] += corr
def finalize(self):
"""
......
......@@ -52,7 +52,7 @@ class DynamicIncoherentStructureFactor(IJob):
Initialize the input parameters and analysis self variables
"""
self.numberOfSteps = self.configuration['atom_selection']['selection_length']
self.numberOfSteps = self.configuration["q_vectors"]["n_shells"]
self._nQShells = self.configuration["q_vectors"]["n_shells"]
......@@ -88,34 +88,41 @@ class DynamicIncoherentStructureFactor(IJob):
#. atomicSF (numpy.array): The atomic structure factor
"""
# get atom index
indexes = self.configuration['atom_selection']["indexes"][index]
masses = self.configuration['atom_selection']["masses"][index]
series = read_atoms_trajectory(self.configuration["trajectory"]["instance"],
indexes,
first=self.configuration['frames']['first'],
last=self.configuration['frames']['last']+1,
step=self.configuration['frames']['step'],
weights=masses)
shell = self.configuration["q_vectors"]["shells"][index]
series = self.configuration['projection']["projector"](series)
if not shell in self.configuration["q_vectors"]["value"]:
return index, None
else:
atomicSF = numpy.zeros((self._nQShells,self._nFrames), dtype=numpy.float64)
qVectors = self.configuration["q_vectors"]["value"][shell]["q_vectors"]
for i,q in enumerate(self.configuration["q_vectors"]["shells"]):
if not q in self.configuration["q_vectors"]["value"]:
continue
qVectors = self.configuration["q_vectors"]["value"][q]["q_vectors"]
disf_per_q_shell = {}
for element in self.configuration['atom_selection']['unique_names']:
disf_per_q_shell[element] = numpy.zeros((self._nFrames,), dtype = numpy.float)
for i,atom_indexes in enumerate(self.configuration['atom_selection']["indexes"]):
masses = self.configuration['atom_selection']["masses"][i]
element = self.configuration['atom_selection']["names"][i]
rho = numpy.exp(1j*numpy.dot(series, qVectors))
res = correlation(rho, axis=0, average=1)
atomicSF[i,:] += res
series = read_atoms_trajectory(self.configuration["trajectory"]["instance"],
atom_indexes,
first=self.configuration['frames']['first'],
last=self.configuration['frames']['last']+1,
step=self.configuration['frames']['step'],
weights=[masses])
series = self.configuration['projection']["projector"](series)
rho = numpy.exp(1j*numpy.dot(series, qVectors))
res = correlation(rho, axis=0, average=1)
disf_per_q_shell[element] += res
return index, atomicSF
return index, disf_per_q_shell
def combine(self, index, x):
......@@ -125,12 +132,11 @@ class DynamicIncoherentStructureFactor(IJob):
#. index (int): The index of the step.\n
#. x (any): The returned result(s) of run_step
"""
element = self.configuration['atom_selection']["names"][index]
self._outputData["f(q,t)_%s" % element] += x
if x is not None:
for k,v in x.items():
self._outputData["f(q,t)_%s" % k][index,:] += v
def finalize(self):
"""
Finalizes the calculations (e.g. averaging the total term, output files creations ...)
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment