Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Scientific Software
MDANSE
Commits
b6892c0b
Commit
b6892c0b
authored
Jan 27, 2016
by
eric pellegrini
Browse files
The frequencies computed (and displayed) is now an angular frequency
parent
d5500e27
Changes
26
Hide whitespace changes
Inline
Side-by-side
MDANSE/Externals/magnitude/magnitude.py
View file @
b6892c0b
...
...
@@ -342,9 +342,9 @@ def _numberp(n): ## Python has to have a decent way to do this!
isinstance
(
n
,
types
.
LongType
))
class
Magnitude
:
def
__init__
(
self
,
val
,
m
=
0
,
s
=
0
,
K
=
0
,
kg
=
0
,
A
=
0
,
mol
=
0
,
cd
=
0
,
dollar
=
0
,
b
=
0
):
def
__init__
(
self
,
val
,
m
=
0
,
s
=
0
,
K
=
0
,
kg
=
0
,
A
=
0
,
mol
=
0
,
cd
=
0
,
dollar
=
0
,
b
=
0
,
rad
=
0
):
self
.
val
=
val
self
.
unit
=
[
m
,
s
,
K
,
kg
,
A
,
mol
,
cd
,
dollar
,
b
]
self
.
unit
=
[
m
,
s
,
K
,
kg
,
A
,
mol
,
cd
,
dollar
,
b
,
rad
]
self
.
out_unit
=
None
self
.
out_factor
=
None
self
.
oprec
=
None
...
...
@@ -1059,10 +1059,11 @@ def _init_mags():
new_mag
(
'$'
,
Magnitude
(
1.0
,
dollar
=
1
))
new_mag
(
'dollar'
,
Magnitude
(
1.0
,
dollar
=
1
))
new_mag
(
'b'
,
Magnitude
(
1.0
,
b
=
1
))
# bit
new_mag
(
'rad'
,
Magnitude
(
1.0
,
rad
=
1
))
# bit
# Magnitudes for derived SI units
new_mag
(
'B'
,
Magnitude
(
8.0
,
b
=
1
))
new_mag
(
'rad'
,
Magnitude
(
1.0
))
# radian
#
new_mag('rad', Magnitude(1.0)) # radian
new_mag
(
'sr'
,
Magnitude
(
1.0
))
# steradian
new_mag
(
'Hz'
,
Magnitude
(
1.0
,
s
=-
1
))
# hertz
new_mag
(
'g'
,
Magnitude
(
1e-3
,
kg
=
1
))
# gram
...
...
@@ -1134,33 +1135,47 @@ def _init_mags():
new_mag
(
'J_per_mole'
,
Magnitude
(
1.66055927e-24
,
m
=
2
,
kg
=
1
,
s
=-
2
))
new_mag
(
'eV'
,
Magnitude
(
1.60217649e-19
,
m
=
2
,
kg
=
1
,
s
=-
2
))
new_mag
(
'Ha'
,
Magnitude
(
4.35974394e-18
,
m
=
2
,
kg
=
1
,
s
=-
2
))
# Eric - frequency
new_mag
(
'rad_inv_s'
,
Magnitude
(
2.0
*
math
.
pi
,
s
=-
1
))
# Energy equivalent
new_mag
(
'inv_m_eq'
,
Magnitude
(
1.9864455e-25
,
m
=
2
,
kg
=
1
,
s
=-
2
))
new_mag
(
'Hz_eq'
,
Magnitude
(
6.62606896e-34
,
m
=
2
,
kg
=
1
,
s
=-
2
))
new_mag
(
'K_eq'
,
Magnitude
(
1.3806504e-23
,
m
=
2
,
kg
=
1
,
s
=-
2
))
new_mag
(
'u_eq'
,
Magnitude
(
1.49241783e-10
,
m
=
2
,
kg
=
1
,
s
=-
2
))
new_mag
(
'1/m_eq'
,
Magnitude
(
1.9864455e-25
,
m
=
2
,
kg
=
1
,
s
=-
2
))
new_mag
(
'hnu'
,
Magnitude
(
6.62606896e-34
,
m
=
2
,
kg
=
1
,
s
=-
2
))
new_mag
(
'T(energy)'
,
Magnitude
(
1.3806504e-23
,
m
=
2
,
kg
=
1
,
s
=-
2
))
new_mag
(
'm(energy)'
,
Magnitude
(
1.49241783e-10
,
m
=
2
,
kg
=
1
,
s
=-
2
))
new_mag
(
'h'
,
Magnitude
(
6.62607004e-34
,
m
=
2
,
kg
=
1
,
s
=-
1
))
new_mag
(
'hbar'
,
Magnitude
(
6.62607004e-34
/
2.0
/
math
.
pi
,
m
=
2
,
kg
=
1
,
s
=-
1
,
rad
=-
1
))
# Frequency equivalent
new_mag
(
'J
_
eq'
,
Magnitude
(
1.50919045e+33
,
s
=-
1
))
new_mag
(
'eV
_
eq'
,
Magnitude
(
2.41798945e+14
,
s
=-
1
))
new_mag
(
'J
(fr
eq
)
'
,
Magnitude
(
1.50919045e+33
,
s
=-
1
))
new_mag
(
'eV
(fr
eq
)
'
,
Magnitude
(
2.41798945e+14
,
s
=-
1
))
# Eric - inverse of distance
new_mag
(
'inv_m'
,
Magnitude
(
1.0
,
m
=-
1
,
kg
=
0
,
s
=
0
))
new_mag
(
'inv_m'
,
Magnitude
(
1.0
,
m
=-
1
,
kg
=
0
,
s
=
0
))
new_mag
(
'inv_um'
,
Magnitude
(
1.0e6
,
m
=-
1
,
kg
=
0
,
s
=
0
))
new_mag
(
'inv_nm'
,
Magnitude
(
1.0e9
,
m
=-
1
,
kg
=
0
,
s
=
0
))
new_mag
(
'inv_ang'
,
Magnitude
(
1.0e10
,
m
=-
1
,
kg
=
0
,
s
=
0
))
# new_mag('1/m', Magnitude(1.0, m=-1, kg=0, s=0))
# new_mag('inv_cm', Magnitude(1.0e2, m=-1, kg=0, s=0))
# new_mag('inv_um', Magnitude(1.0e6, m=-1, kg=0, s=0))
# new_mag('inv_nm', Magnitude(1.0e9, m=-1, kg=0, s=0))
# new_mag('inv_ang', Magnitude(1.0e10, m=-1, kg=0, s=0))
new_mag
(
'cyc'
,
Magnitude
(
2.0
*
math
.
pi
,
rad
=
1
))
new_mag
(
'au'
,
Magnitude
(
1.0
))
new_mag
(
'wu'
,
Magnitude
(
1.0
))
new_mag
(
'unitless'
,
Magnitude
(
1.0
))
new_mag
(
'no-unit'
,
Magnitude
(
1.0
))
# Eric - frequency
# new_mag('rad_inv_s', Magnitude(1.0, s=-1))
# new_mag('rad_inv_ps', Magnitude(1.0e12, s=-1))
if
not
MAGS
:
_init_mags
()
if
__name__
==
"__main__"
:
print
mg
(
1.0
,
'h THz'
,
'meV'
)
print
mg
(
1.0
,
'meV/h'
,
'THz'
)
print
mg
(
1.0
,
'hbar rad/ps'
,
'meV'
)
print
mg
(
1.0
,
'cyc THz'
,
'rad/ps'
)
print
mg
(
1.0
,
'rad/ps'
,
' cyc THz'
)
print
mg
(
1.0
,
'rad/ps'
,
' cyc meV(freq)'
)
MDANSE/Framework/Configurators/InstrumentResolutionConfigurator.py
View file @
b6892c0b
...
...
@@ -33,7 +33,7 @@ Created on Mar 30, 2015
import
numpy
from
MDANSE
import
REGISTRY
from
MDANSE.Framework.Configurators.IConfigurator
import
IConfigurator
,
ConfiguratorError
from
MDANSE.Framework.Configurators.IConfigurator
import
IConfigurator
class
InstrumentResolutionConfigurator
(
IConfigurator
):
"""
...
...
@@ -43,7 +43,7 @@ class InstrumentResolutionConfigurator(IConfigurator):
of states) when performing the fourier transform of its time-dependant counterpart. This allow to
convolute of the signal with a resolution function to have a better match with experimental spectrum.
In MDANSE, the instrument resolution are defined in
frequency (energy)
space and are internally
In MDANSE, the instrument resolution are defined in
omegas
space and are internally
inverse-fourier-transformed to get a time-dependant version. This time-dependant resolution function will then
be multiplied by the time-dependant signal to get the resolution effect according to the Fourier Transform theorem:
...
...
@@ -83,11 +83,10 @@ class InstrumentResolutionConfigurator(IConfigurator):
self
.
_timeStep
=
framesCfg
[
'time'
][
1
]
-
framesCfg
[
'time'
][
0
]
self
[
'time_step'
]
=
self
.
_timeStep
self
[
"frequencies"
]
=
numpy
.
fft
.
fftshift
(
numpy
.
fft
.
fftfreq
(
2
*
self
[
"n_frames"
]
-
1
,
self
[
"time_step"
]))
df
=
round
(
self
[
"frequencies"
][
1
]
-
self
[
"frequencies"
][
0
],
3
)
self
[
"n_frequencies"
]
=
len
(
self
[
"frequencies"
])
# We compute angular frequency AND NOT ORDINARY FREQUENCY ANYMORE
self
[
"omega"
]
=
2.0
*
numpy
.
pi
*
numpy
.
fft
.
fftshift
(
numpy
.
fft
.
fftfreq
(
2
*
self
[
"n_frames"
]
-
1
,
self
[
"time_step"
]))
self
[
"n_omegas"
]
=
len
(
self
[
"omega"
])
kernel
,
parameters
=
value
...
...
@@ -97,21 +96,11 @@ class InstrumentResolutionConfigurator(IConfigurator):
resolution
.
setup
(
parameters
)
resolution
.
set_kernel
(
self
[
"frequencies"
],
self
[
"time_step"
])
dmax
=
resolution
.
timeWindow
.
max
()
-
1
if
dmax
>
0.1
:
raise
ConfiguratorError
(
'''the resolution function is too sharp for the available frequency step.
You can change your resolution function settings to make it broader or use "ideal" kernel if you do not want to smooth your signal.
For a gaussian resolution function, this would correspond to a sigma at least equal to the frequency step (%s)'''
%
df
,
self
)
elif
dmax
<
-
0.1
:
raise
ConfiguratorError
(
'''the resolution function is too broad.
You should change your resolution function settings to make it sharper.'''
,
self
)
resolution
.
set_kernel
(
self
[
"omega"
],
self
[
"time_step"
])
self
[
"
frequency
_window"
]
=
resolution
.
frequency
Window
self
[
"
omega
_window"
]
=
resolution
.
omega
Window
self
[
"time_window"
]
=
resolution
.
timeWindow
self
[
"time_window"
]
=
resolution
.
timeWindow
.
real
self
[
"kernel"
]
=
kernel
self
[
"parameters"
]
=
parameters
...
...
MDANSE/Framework/InstrumentResolutions/GaussianResolution.py
View file @
b6892c0b
...
...
@@ -46,10 +46,10 @@ class GaussianInstrumentResolution(IInstrumentResolution):
settings
[
'mu'
]
=
(
'float'
,
{
"default"
:
0.0
})
settings
[
'sigma'
]
=
(
'float'
,
{
"default"
:
1.0
})
def
set_kernel
(
self
,
frequencie
s
,
dt
):
def
set_kernel
(
self
,
omega
s
,
dt
):
mu
=
self
.
_configuration
[
"mu"
][
"value"
]
sigma
=
self
.
_configuration
[
"sigma"
][
"value"
]
self
.
_
frequency
Window
=
(
numpy
.
sqrt
(
2.0
*
numpy
.
pi
)
/
sigma
)
*
numpy
.
exp
(
-
0.5
*
((
frequencie
s
-
mu
)
/
sigma
)
**
2
)
self
.
_timeWindow
=
numpy
.
fft
.
fftshift
(
numpy
.
fft
.
ifft
(
numpy
.
fft
.
ifftshift
(
self
.
_
frequency
Window
))
/
dt
)
self
.
_
omega
Window
=
(
numpy
.
sqrt
(
2.0
*
numpy
.
pi
)
/
sigma
)
*
numpy
.
exp
(
-
0.5
*
((
omega
s
-
mu
)
/
sigma
)
**
2
)
self
.
_timeWindow
=
numpy
.
fft
.
fftshift
(
numpy
.
fft
.
ifft
(
numpy
.
fft
.
ifftshift
(
self
.
_
omega
Window
))
/
dt
)
MDANSE/Framework/InstrumentResolutions/IInstrumentResolution.py
View file @
b6892c0b
...
...
@@ -49,21 +49,21 @@ class IInstrumentResolution(Configurable):
Configurable
.
__init__
(
self
)
self
.
_
frequency
Window
=
None
self
.
_
omega
Window
=
None
self
.
_timeWindow
=
None
@
abc
.
abstractmethod
def
set_kernel
(
self
,
frequencie
s
,
dt
):
def
set_kernel
(
self
,
omega
s
,
dt
):
pass
@
property
def
frequency
Window
(
self
):
def
omega
Window
(
self
):
if
self
.
_
frequency
Window
is
None
:
raise
InstrumentResolutionError
(
"Undefined
frequency
window"
)
if
self
.
_
omega
Window
is
None
:
raise
InstrumentResolutionError
(
"Undefined
omega
window"
)
return
self
.
_
frequency
Window
return
self
.
_
omega
Window
@
property
def
timeWindow
(
self
):
...
...
MDANSE/Framework/InstrumentResolutions/IdealResolution.py
View file @
b6892c0b
...
...
@@ -44,9 +44,10 @@ class IdealInstrumentResolution(IInstrumentResolution):
settings
=
collections
.
OrderedDict
()
def
set_kernel
(
self
,
frequencie
s
,
dt
):
def
set_kernel
(
self
,
omega
s
,
dt
):
self
.
_frequencyWindow
=
numpy
.
zeros
(
len
(
frequencies
),
dtype
=
numpy
.
float64
)
self
.
_frequencyWindow
[
len
(
frequencies
)
/
2
]
=
1.0
nOmegas
=
len
(
omegas
)
self
.
_omegaWindow
=
numpy
.
zeros
(
nOmegas
,
dtype
=
numpy
.
float64
)
self
.
_omegaWindow
[
nOmegas
/
2
]
=
1.0
self
.
_timeWindow
=
numpy
.
ones
(
len
(
frequencies
),
dtype
=
numpy
.
float64
)
\ No newline at end of file
self
.
_timeWindow
=
numpy
.
ones
(
nOmegas
,
dtype
=
numpy
.
float64
)
\ No newline at end of file
MDANSE/Framework/InstrumentResolutions/LorentzianResolution.py
View file @
b6892c0b
...
...
@@ -47,11 +47,11 @@ class LorentzianInstrumentResolution(IInstrumentResolution):
settings
[
'mu'
]
=
(
'float'
,
{
"default"
:
0.0
})
settings
[
'sigma'
]
=
(
'float'
,
{
"default"
:
1.0
})
def
set_kernel
(
self
,
frequencie
s
,
dt
):
def
set_kernel
(
self
,
omega
s
,
dt
):
mu
=
self
.
_configuration
[
"mu"
][
"value"
]
sigma
=
self
.
_configuration
[
"sigma"
][
"value"
]
self
.
_
frequency
Window
=
(
2.0
*
sigma
)
/
((
frequencie
s
-
mu
)
**
2
+
sigma
**
2
)
self
.
_timeWindow
=
numpy
.
fft
.
fftshift
(
numpy
.
fft
.
ifft
(
numpy
.
fft
.
ifftshift
(
self
.
_
frequency
Window
))
/
dt
)
self
.
_
omega
Window
=
(
2.0
*
sigma
)
/
((
omega
s
-
mu
)
**
2
+
sigma
**
2
)
self
.
_timeWindow
=
numpy
.
fft
.
fftshift
(
numpy
.
fft
.
ifft
(
numpy
.
fft
.
ifftshift
(
self
.
_
omega
Window
))
/
dt
)
\ No newline at end of file
MDANSE/Framework/InstrumentResolutions/PseudoVoigtResolution.py
View file @
b6892c0b
...
...
@@ -49,7 +49,7 @@ class PseudoVoigtInstrumentResolution(IInstrumentResolution):
settings
[
'mu_gaussian'
]
=
(
'float'
,
{
"default"
:
0.0
})
settings
[
'sigma_gaussian'
]
=
(
'float'
,
{
"default"
:
1.0
})
def
set_kernel
(
self
,
frequencie
s
,
dt
):
def
set_kernel
(
self
,
omega
s
,
dt
):
eta
=
self
.
_configuration
[
"eta"
][
"value"
]
muL
=
self
.
_configuration
[
"mu_lorentzian"
][
"value"
]
...
...
@@ -57,10 +57,10 @@ class PseudoVoigtInstrumentResolution(IInstrumentResolution):
muG
=
self
.
_configuration
[
"mu_gaussian"
][
"value"
]
sigmaG
=
self
.
_configuration
[
"sigma_gaussian"
][
"value"
]
gaussian
=
(
numpy
.
sqrt
(
2.0
*
numpy
.
pi
)
/
sigmaG
)
*
numpy
.
exp
(
-
0.5
*
((
frequencie
s
-
muG
)
/
sigmaG
)
**
2
)
gaussian
=
(
numpy
.
sqrt
(
2.0
*
numpy
.
pi
)
/
sigmaG
)
*
numpy
.
exp
(
-
0.5
*
((
omega
s
-
muG
)
/
sigmaG
)
**
2
)
lorentzian
=
(
2.0
*
sigmaL
)
/
((
frequencie
s
-
muL
)
**
2
+
sigmaL
**
2
)
lorentzian
=
(
2.0
*
sigmaL
)
/
((
omega
s
-
muL
)
**
2
+
sigmaL
**
2
)
self
.
_
frequency
Window
=
eta
*
lorentzian
+
(
1.0
-
eta
)
*
gaussian
self
.
_timeWindow
=
numpy
.
fft
.
fftshift
(
numpy
.
fft
.
ifft
(
numpy
.
fft
.
ifftshift
(
self
.
_
frequency
Window
))
/
dt
)
self
.
_
omega
Window
=
eta
*
lorentzian
+
(
1.0
-
eta
)
*
gaussian
self
.
_timeWindow
=
numpy
.
fft
.
fftshift
(
numpy
.
fft
.
ifft
(
numpy
.
fft
.
ifftshift
(
self
.
_
omega
Window
))
/
dt
)
\ No newline at end of file
MDANSE/Framework/InstrumentResolutions/SquareResolution.py
View file @
b6892c0b
...
...
@@ -46,12 +46,12 @@ class SquareInstrumentResolution(IInstrumentResolution):
settings
[
'mu'
]
=
(
'float'
,
{
"default"
:
0.0
})
settings
[
'sigma'
]
=
(
'float'
,
{
"default"
:
1.0
})
def
set_kernel
(
self
,
frequencie
s
,
dt
):
def
set_kernel
(
self
,
omega
s
,
dt
):
mu
=
self
.
_configuration
[
"mu"
][
"value"
]
sigma
=
self
.
_configuration
[
"sigma"
][
"value"
]
self
.
_
frequency
Window
=
2.0
*
numpy
.
pi
*
numpy
.
where
((
numpy
.
abs
(
frequencie
s
-
mu
)
-
sigma
)
>
0
,
0.0
,
1.0
/
(
2.0
*
sigma
))
self
.
_
omega
Window
=
2.0
*
numpy
.
pi
*
numpy
.
where
((
numpy
.
abs
(
omega
s
-
mu
)
-
sigma
)
>
0
,
0.0
,
1.0
/
(
2.0
*
sigma
))
self
.
_timeWindow
=
numpy
.
fft
.
fftshift
(
numpy
.
fft
.
ifft
(
numpy
.
fft
.
ifftshift
(
self
.
_
frequency
Window
))
/
dt
)
self
.
_timeWindow
=
numpy
.
fft
.
fftshift
(
numpy
.
fft
.
ifft
(
numpy
.
fft
.
ifftshift
(
self
.
_
omega
Window
))
/
dt
)
\ No newline at end of file
MDANSE/Framework/InstrumentResolutions/TriangularResolution.py
View file @
b6892c0b
...
...
@@ -46,13 +46,13 @@ class TriangularInstrumentResolution(IInstrumentResolution):
settings
[
'mu'
]
=
(
'float'
,
{
"default"
:
0.0
})
settings
[
'sigma'
]
=
(
'float'
,
{
"default"
:
1.0
})
def
set_kernel
(
self
,
frequencie
s
,
dt
):
def
set_kernel
(
self
,
omega
s
,
dt
):
mu
=
self
.
_configuration
[
"mu"
][
"value"
]
sigma
=
self
.
_configuration
[
"sigma"
][
"value"
]
val
=
numpy
.
abs
(
frequencie
s
-
mu
)
-
sigma
val
=
numpy
.
abs
(
omega
s
-
mu
)
-
sigma
self
.
_
frequency
Window
=
2.0
*
numpy
.
pi
*
numpy
.
where
(
val
>=
0
,
0.0
,
-
val
/
sigma
**
2
)
self
.
_
omega
Window
=
2.0
*
numpy
.
pi
*
numpy
.
where
(
val
>=
0
,
0.0
,
-
val
/
sigma
**
2
)
self
.
_timeWindow
=
numpy
.
fft
.
fftshift
(
numpy
.
fft
.
ifft
(
numpy
.
fft
.
ifftshift
(
self
.
_
frequency
Window
))
/
dt
)
self
.
_timeWindow
=
numpy
.
fft
.
fftshift
(
numpy
.
fft
.
ifft
(
numpy
.
fft
.
ifftshift
(
self
.
_
omega
Window
))
/
dt
)
MDANSE/Framework/Jobs/AngularCorrelation.py
View file @
b6892c0b
...
...
@@ -86,14 +86,14 @@ class AngularCorrelation(IJob):
self
.
numberOfSteps
=
self
.
configuration
[
'axis_selection'
][
'n_values'
]
self
.
_outputData
.
add
(
"time
s
"
,
"line"
,
self
.
configuration
[
'frames'
][
'time'
],
units
=
'ps'
)
self
.
_outputData
.
add
(
"time"
,
"line"
,
self
.
configuration
[
'frames'
][
'time'
],
units
=
'ps'
)
self
.
_outputData
.
add
(
"axis_index"
,
"line"
,
numpy
.
arange
(
self
.
configuration
[
'axis_selection'
][
'n_values'
]),
units
=
'au'
)
self
.
_outputData
.
add
(
'ac'
,
"line"
,
(
self
.
configuration
[
'frames'
][
'number'
],),
axis
=
"time
s
"
,
units
=
"au"
)
self
.
_outputData
.
add
(
'ac'
,
"line"
,
(
self
.
configuration
[
'frames'
][
'number'
],),
axis
=
"time"
,
units
=
"au"
)
if
self
.
configuration
[
'per_axis'
][
'value'
]:
self
.
_outputData
.
add
(
'ac_per_axis'
,
"surface"
,
(
self
.
configuration
[
'axis_selection'
][
'n_values'
],
self
.
configuration
[
'frames'
][
'number'
],),
axis
=
'axis_index|time
s
'
,
units
=
"au"
)
self
.
_outputData
.
add
(
'ac_per_axis'
,
"surface"
,
(
self
.
configuration
[
'axis_selection'
][
'n_values'
],
self
.
configuration
[
'frames'
][
'number'
],),
axis
=
'axis_index|time'
,
units
=
"au"
)
def
run_step
(
self
,
index
):
"""
...
...
MDANSE/Framework/Jobs/AreaPerMolecule.py
View file @
b6892c0b
...
...
@@ -82,9 +82,9 @@ class AreaPerMolecule(IJob):
if
self
.
_nMolecules
==
0
:
raise
AreaPerMoleculeError
(
"No molecule matches %r name."
%
self
.
configuration
[
"name"
][
"value"
])
self
.
_outputData
.
add
(
"time
s
"
,
"line"
,
self
.
configuration
[
'frames'
][
'time'
],
units
=
'ps'
)
self
.
_outputData
.
add
(
"time"
,
"line"
,
self
.
configuration
[
'frames'
][
'time'
],
units
=
'ps'
)
self
.
_outputData
.
add
(
"area_per_molecule"
,
"line"
,
(
self
.
configuration
[
'frames'
][
'number'
],),
axis
=
"time
s
"
,
units
=
"1/nm2"
)
self
.
_outputData
.
add
(
"area_per_molecule"
,
"line"
,
(
self
.
configuration
[
'frames'
][
'number'
],),
axis
=
"time"
,
units
=
"1/nm2"
)
def
run_step
(
self
,
index
):
"""
...
...
MDANSE/Framework/Jobs/CurrentCorrelationFunction.py
View file @
b6892c0b
...
...
@@ -82,13 +82,15 @@ class CurrentCorrelationFunction(IJob):
self
.
_instrResolution
=
self
.
configuration
[
"instrument_resolution"
]
self
.
_n
Frequencie
s
=
self
.
_instrResolution
[
'n_
frequencie
s'
]
self
.
_n
Omega
s
=
self
.
_instrResolution
[
'n_
omega
s'
]
self
.
_outputData
.
add
(
"q"
,
"line"
,
numpy
.
array
(
self
.
configuration
[
"q_vectors"
][
"shells"
]),
units
=
"inv_nm"
)
self
.
_outputData
.
add
(
"times"
,
"line"
,
self
.
configuration
[
'frames'
][
'time'
],
units
=
'ps'
)
self
.
_outputData
.
add
(
"time"
,
"line"
,
self
.
configuration
[
'frames'
][
'time'
],
units
=
'ps'
)
self
.
_outputData
.
add
(
"time_window"
,
"line"
,
self
.
_instrResolution
[
"time_window"
],
units
=
"au"
)
self
.
_outputData
.
add
(
"frequency"
,
"line"
,
self
.
_instrResolution
[
"frequencies"
],
units
=
'THz'
)
self
.
_outputData
.
add
(
"omega"
,
"line"
,
self
.
_instrResolution
[
"omega"
],
units
=
'rad/ps'
)
self
.
_outputData
.
add
(
"omega_window"
,
"line"
,
self
.
_instrResolution
[
"omega_window"
],
axis
=
"omega"
,
units
=
"au"
)
self
.
_elements
=
self
.
configuration
[
'atom_selection'
][
'unique_names'
]
self
.
_elementsPairs
=
sorted
(
itertools
.
combinations_with_replacement
(
self
.
_elements
,
2
))
...
...
@@ -96,15 +98,15 @@ class CurrentCorrelationFunction(IJob):
self
.
_indexesPerElement
=
self
.
configuration
[
'atom_selection'
].
get_indexes
()
for
pair
in
self
.
_elementsPairs
:
self
.
_outputData
.
add
(
"j(q,t)_long_%s%s"
%
pair
,
"surface"
,
(
nQShells
,
self
.
_nFrames
),
axis
=
"q|time
s
"
,
units
=
"au"
)
self
.
_outputData
.
add
(
"j(q,t)_trans_%s%s"
%
pair
,
"surface"
,
(
nQShells
,
self
.
_nFrames
),
axis
=
"q|time
s
"
,
units
=
"au"
)
self
.
_outputData
.
add
(
"J(q,f)_long_%s%s"
%
pair
,
"surface"
,
(
nQShells
,
self
.
_n
Frequencie
s
),
axis
=
"q|
frequency
"
,
units
=
"au"
)
self
.
_outputData
.
add
(
"J(q,f)_trans_%s%s"
%
pair
,
"surface"
,
(
nQShells
,
self
.
_n
Frequencie
s
),
axis
=
"q|
frequency
"
,
units
=
"au"
)
self
.
_outputData
.
add
(
"j(q,t)_long_total"
,
"surface"
,
(
nQShells
,
self
.
_nFrames
),
axis
=
"q|time
s
"
,
units
=
"au"
)
self
.
_outputData
.
add
(
"J(q,f)_long_total"
,
"surface"
,
(
nQShells
,
self
.
_n
Frequencie
s
),
axis
=
"q|
frequency
"
,
units
=
"au"
)
self
.
_outputData
.
add
(
"j(q,t)_trans_total"
,
"surface"
,
(
nQShells
,
self
.
_nFrames
),
axis
=
"q|time
s
"
,
units
=
"au"
)
self
.
_outputData
.
add
(
"J(q,f)_trans_total"
,
"surface"
,
(
nQShells
,
self
.
_n
Frequencie
s
),
axis
=
"q|
frequency
"
,
units
=
"au"
)
self
.
_outputData
.
add
(
"j(q,t)_long_%s%s"
%
pair
,
"surface"
,
(
nQShells
,
self
.
_nFrames
),
axis
=
"q|time"
,
units
=
"au"
)
self
.
_outputData
.
add
(
"j(q,t)_trans_%s%s"
%
pair
,
"surface"
,
(
nQShells
,
self
.
_nFrames
),
axis
=
"q|time"
,
units
=
"au"
)
self
.
_outputData
.
add
(
"J(q,f)_long_%s%s"
%
pair
,
"surface"
,
(
nQShells
,
self
.
_n
Omega
s
),
axis
=
"q|
omega
"
,
units
=
"au"
)
self
.
_outputData
.
add
(
"J(q,f)_trans_%s%s"
%
pair
,
"surface"
,
(
nQShells
,
self
.
_n
Omega
s
),
axis
=
"q|
omega
"
,
units
=
"au"
)
self
.
_outputData
.
add
(
"j(q,t)_long_total"
,
"surface"
,
(
nQShells
,
self
.
_nFrames
),
axis
=
"q|time"
,
units
=
"au"
)
self
.
_outputData
.
add
(
"J(q,f)_long_total"
,
"surface"
,
(
nQShells
,
self
.
_n
Omega
s
),
axis
=
"q|
omega
"
,
units
=
"au"
)
self
.
_outputData
.
add
(
"j(q,t)_trans_total"
,
"surface"
,
(
nQShells
,
self
.
_nFrames
),
axis
=
"q|time"
,
units
=
"au"
)
self
.
_outputData
.
add
(
"J(q,f)_trans_total"
,
"surface"
,
(
nQShells
,
self
.
_n
Omega
s
),
axis
=
"q|
omega
"
,
units
=
"au"
)
def
run_step
(
self
,
index
):
"""
...
...
MDANSE/Framework/Jobs/Density.py
View file @
b6892c0b
...
...
@@ -67,11 +67,11 @@ class Density(IJob):
self
.
_symbols
=
sorted_atoms
(
self
.
configuration
[
'trajectory'
][
'instance'
].
universe
,
"symbol"
)
# Will store the time.
self
.
_outputData
.
add
(
"time
s
"
,
"line"
,
self
.
configuration
[
'frames'
][
'time'
],
units
=
'ps'
)
self
.
_outputData
.
add
(
"time"
,
"line"
,
self
.
configuration
[
'frames'
][
'time'
],
units
=
'ps'
)
self
.
_outputData
.
add
(
"mass_density"
,
"line"
,
(
self
.
_nFrames
,),
units
=
'g/cm3'
)
self
.
_outputData
.
add
(
"mass_density"
,
"line"
,
(
self
.
_nFrames
,),
axis
=
'time'
,
units
=
'g/cm3'
)
self
.
_outputData
.
add
(
"atomic_density"
,
"line"
,
(
self
.
_nFrames
,),
units
=
'1/cm3'
)
self
.
_outputData
.
add
(
"atomic_density"
,
"line"
,
(
self
.
_nFrames
,),
axis
=
'time'
,
units
=
'1/cm3'
)
if
not
self
.
configuration
[
'trajectory'
][
'instance'
].
universe
.
is_periodic
:
raise
JobError
(
"Pair distribution function cannot be calculated for infinite universe trajectories"
)
...
...
MDANSE/Framework/Jobs/DensityOfStates.py
View file @
b6892c0b
...
...
@@ -77,14 +77,14 @@ class DensityOfStates(IJob):
self
.
_outputData
.
add
(
"time"
,
"line"
,
self
.
configuration
[
'frames'
][
'time'
],
units
=
'ps'
)
self
.
_outputData
.
add
(
"time_window"
,
"line"
,
instrResolution
[
"time_window"
],
axis
=
"time"
,
units
=
"au"
)
self
.
_outputData
.
add
(
"
frequency
"
,
"line"
,
instrResolution
[
"
frequencies
"
],
units
=
'
THz
'
)
self
.
_outputData
.
add
(
"
frequency
_window"
,
"line"
,
instrResolution
[
"
frequency
_window"
],
axis
=
"
frequency
"
,
units
=
"au"
)
self
.
_outputData
.
add
(
"
omega
"
,
"line"
,
instrResolution
[
"
omega
"
],
units
=
'
rad/ps
'
)
self
.
_outputData
.
add
(
"
omega
_window"
,
"line"
,
instrResolution
[
"
omega
_window"
],
axis
=
"
omega
"
,
units
=
"au"
)
for
element
in
self
.
configuration
[
'atom_selection'
][
'unique_names'
]:
self
.
_outputData
.
add
(
"vacf_%s"
%
element
,
"line"
,
(
self
.
configuration
[
'frames'
][
'number'
],),
axis
=
"time"
,
units
=
"nm2/ps2"
)
self
.
_outputData
.
add
(
"dos_%s"
%
element
,
"line"
,
(
instrResolution
[
'n_
frequencie
s'
],),
axis
=
"
frequency
"
,
units
=
"nm2/ps"
)
self
.
_outputData
.
add
(
"dos_%s"
%
element
,
"line"
,
(
instrResolution
[
'n_
omega
s'
],),
axis
=
"
omega
"
,
units
=
"nm2/ps"
)
self
.
_outputData
.
add
(
"vacf_total"
,
"line"
,
(
self
.
configuration
[
'frames'
][
'number'
],),
axis
=
"time"
,
units
=
"nm2/ps2"
)
self
.
_outputData
.
add
(
"dos_total"
,
"line"
,
(
instrResolution
[
'n_
frequencie
s'
],),
axis
=
"
frequency
"
,
units
=
"nm2/ps"
)
self
.
_outputData
.
add
(
"dos_total"
,
"line"
,
(
instrResolution
[
'n_
omega
s'
],),
axis
=
"
omega
"
,
units
=
"nm2/ps"
)
def
run_step
(
self
,
index
):
"""
...
...
MDANSE/Framework/Jobs/DensityProfile.py
View file @
b6892c0b
...
...
@@ -148,7 +148,7 @@ class DensityProfile(IJob):
dpTotal
=
weight
(
self
.
configuration
[
"weights"
].
get_weights
(),
self
.
_outputData
,
nAtomsPerElement
,
1
,
"dp_%s"
)
self
.
_outputData
.
add
(
"dp_total"
,
"line"
,
dpTotal
,
axis
=
"time
s
"
,
units
=
"au"
)
self
.
_outputData
.
add
(
"dp_total"
,
"line"
,
dpTotal
,
axis
=
"time"
,
units
=
"au"
)
self
.
_extent
/=
self
.
numberOfSteps
...
...
MDANSE/Framework/Jobs/DynamicCoherentStructureFactor.py
View file @
b6892c0b
...
...
@@ -88,25 +88,25 @@ class DynamicCoherentStructureFactor(IJob):
self
.
_instrResolution
=
self
.
configuration
[
"instrument_resolution"
]
self
.
_n
Frequencie
s
=
self
.
_instrResolution
[
'n_
frequencie
s'
]
self
.
_n
Omega
s
=
self
.
_instrResolution
[
'n_
omega
s'
]
self
.
_outputData
.
add
(
"q"
,
"line"
,
self
.
configuration
[
"q_vectors"
][
"shells"
],
units
=
"inv_nm"
)
self
.
_outputData
.
add
(
"time"
,
"line"
,
self
.
configuration
[
'frames'
][
'time'
],
units
=
'ps'
)
self
.
_outputData
.
add
(
"time_window"
,
"line"
,
self
.
_instrResolution
[
"time_window"
],
axis
=
"time"
,
units
=
"au"
)
self
.
_outputData
.
add
(
"time_window"
,
"line"
,
self
.
_instrResolution
[
"time_window"
],
units
=
"au"
)
self
.
_outputData
.
add
(
"
frequency
"
,
"line"
,
self
.
_instrResolution
[
"
frequencies
"
],
units
=
'
THz
'
)
self
.
_outputData
.
add
(
"
frequency
_window"
,
"line"
,
self
.
_instrResolution
[
"
frequency
_window"
],
axis
=
"
frequency
"
,
units
=
"au"
)
self
.
_outputData
.
add
(
"
omega
"
,
"line"
,
self
.
_instrResolution
[
"
omega
"
],
units
=
'
rad/ps
'
)
self
.
_outputData
.
add
(
"
omega
_window"
,
"line"
,
self
.
_instrResolution
[
"
omega
_window"
],
axis
=
"
omega
"
,
units
=
"au"
)
self
.
_elementsPairs
=
sorted
(
itertools
.
combinations_with_replacement
(
self
.
configuration
[
'atom_selection'
][
'unique_names'
],
2
))
self
.
_indexesPerElement
=
self
.
configuration
[
'atom_selection'
].
get_indexes
()
for
pair
in
self
.
_elementsPairs
:
self
.
_outputData
.
add
(
"f(q,t)_%s%s"
%
pair
,
"surface"
,
(
nQShells
,
self
.
_nFrames
),
axis
=
"q|time"
,
units
=
"au"
)
self
.
_outputData
.
add
(
"s(q,f)_%s%s"
%
pair
,
"surface"
,
(
nQShells
,
self
.
_n
Frequencie
s
),
axis
=
"q|
frequency
"
,
units
=
"nm2/ps"
)
self
.
_outputData
.
add
(
"f(q,t)_%s%s"
%
pair
,
"surface"
,
(
nQShells
,
self
.
_nFrames
),
axis
=
"q|time"
,
units
=
"au"
)
self
.
_outputData
.
add
(
"s(q,f)_%s%s"
%
pair
,
"surface"
,
(
nQShells
,
self
.
_n
Omega
s
),
axis
=
"q|
omega
"
,
units
=
"nm2/ps"
)
self
.
_outputData
.
add
(
"f(q,t)_total"
,
"surface"
,
(
nQShells
,
self
.
_nFrames
),
axis
=
"q|time"
,
units
=
"au"
)
self
.
_outputData
.
add
(
"s(q,f)_total"
,
"surface"
,
(
nQShells
,
self
.
_n
Frequencie
s
),
axis
=
"q|
frequency
"
,
units
=
"nm2/ps"
)
self
.
_outputData
.
add
(
"s(q,f)_total"
,
"surface"
,
(
nQShells
,
self
.
_n
Omega
s
),
axis
=
"q|
omega
"
,
units
=
"nm2/ps"
)
def
run_step
(
self
,
index
):
"""
...
...
@@ -176,7 +176,7 @@ class DynamicCoherentStructureFactor(IJob):
self
.
_outputData
[
"s(q,f)_%s%s"
%
pair
][:]
=
get_spectrum
(
self
.
_outputData
[
"f(q,t)_%s%s"
%
pair
],
self
.
configuration
[
"instrument_resolution"
][
"time_window"
],
self
.
configuration
[
"instrument_resolution"
][
"time_step"
],
axis
=
1
)
axis
=
1
)
fqtTotal
=
weight
(
self
.
configuration
[
"weights"
].
get_weights
(),
self
.
_outputData
,
nAtomsPerElement
,
2
,
"f(q,t)_%s%s"
)
...
...
MDANSE/Framework/Jobs/DynamicIncoherentStructureFactor.py
View file @
b6892c0b
...
...
@@ -79,22 +79,22 @@ class DynamicIncoherentStructureFactor(IJob):
self
.
_instrResolution
=
self
.
configuration
[
"instrument_resolution"
]
self
.
_n
Frequencie
s
=
self
.
_instrResolution
[
'n_
frequencie
s'
]
self
.
_n
Omega
s
=
self
.
_instrResolution
[
'n_
omega
s'
]
self
.
_outputData
.
add
(
"q"
,
"line"
,
self
.
configuration
[
"q_vectors"
][
"shells"
],
units
=
"inv_nm"
)
self
.
_outputData
.
add
(
"time"
,
"line"
,
self
.
configuration
[
'frames'
][
'time'
],
units
=
'ps'
)
self
.
_outputData
.
add
(
"time_window"
,
"line"
,
self
.
_instrResolution
[
"time_window"
],
axis
=
"time"
,
units
=
"au"
)
self
.
_outputData
.
add
(
"
frequency
"
,
"line"
,
self
.
_instrResolution
[
"
frequencies
"
],
units
=
'
THz
'
)
self
.
_outputData
.
add
(
"
frequency
_window"
,
"line"
,
self
.
_instrResolution
[
"
frequency
_window"
],
axis
=
"
frequency
"
,
units
=
"au"
)
self
.
_outputData
.
add
(
"
omega
"
,
"line"
,
self
.
_instrResolution
[
"
omega
"
],
units
=
'
rad/ps
'
)
self
.
_outputData
.
add
(
"
omega
_window"
,
"line"
,
self
.
_instrResolution
[
"
omega
_window"
],
axis
=
"
omega
"
,
units
=
"au"
)
for
element
in
self
.
configuration
[
'atom_selection'
][
'unique_names'
]:
self
.
_outputData
.
add
(
"f(q,t)_%s"
%
element
,
"surface"
,
(
self
.
_nQShells
,
self
.
_nFrames
)
,
axis
=
"q|time"
,
units
=
"au"
)
self
.
_outputData
.
add
(
"s(q,f)_%s"
%
element
,
"surface"
,
(
self
.
_nQShells
,
self
.
_n
Frequencie
s
),
axis
=
"q|
frequency
"
,
units
=
"nm2/ps"
)
self
.
_outputData
.
add
(
"s(q,f)_%s"
%
element
,
"surface"
,
(
self
.
_nQShells
,
self
.
_n
Omega
s
),
axis
=
"q|
omega
"
,
units
=
"nm2/ps"
)
self
.
_outputData
.
add
(
"f(q,t)_total"
,
"surface"
,
(
self
.
_nQShells
,
self
.
_nFrames
)
,
axis
=
"q|time"
,
units
=
"au"
)
self
.
_outputData
.
add
(
"s(q,f)_total"
,
"surface"
,
(
self
.
_nQShells
,
self
.
_n
Frequencie
s
),
axis
=
"q|
frequency
"
,
units
=
"nm2/ps"
)
self
.
_outputData
.
add
(
"s(q,f)_total"
,
"surface"
,
(
self
.
_nQShells
,
self
.
_n
Omega
s
),
axis
=
"q|
omega
"
,
units
=
"nm2/ps"
)
def
run_step
(
self
,
index
):
"""
...
...
MDANSE/Framework/Jobs/GaussianDynamicIncoherentStructureFactor.py
View file @
b6892c0b
...
...
@@ -79,7 +79,7 @@ class GaussianDynamicIncoherentStructureFactor(IJob):
self
.
_instrResolution
=
self
.
configuration
[
"instrument_resolution"
]
self
.
_n
Frequencie
s
=
self
.
_instrResolution
[
'n_
frequencie
s'
]
self
.
_n
Omega
s
=
self
.
_instrResolution
[
'n_
omega
s'
]
self
.
_kSquare
=
self
.
configuration
[
"q_shells"
][
"value"
]
**
2
...
...
@@ -87,18 +87,18 @@ class GaussianDynamicIncoherentStructureFactor(IJob):
self
.
_outputData
.
add
(
"q2"
,
"line"
,
self
.
_kSquare
,
units
=
"inv_nm**2"
)
self
.
_outputData
.
add
(
"time
s
"
,
"line"
,
self
.
configuration
[
'frames'
][
'time'
],
units
=
'ps'
)
self
.
_outputData
.
add
(
"time_window"
,
"line"
,
self
.
_instrResolution
[
"time_window"
],
axis
=
"time
s
"
,
units
=
"au"
)
self
.
_outputData
.
add
(
"time"
,
"line"
,
self
.
configuration
[
'frames'
][
'time'
],
units
=
'ps'
)
self
.
_outputData
.
add
(
"time_window"
,
"line"
,
self
.
_instrResolution
[
"time_window"
],
axis
=
"time"
,
units
=
"au"
)
self
.
_outputData
.
add
(
"
frequency
"
,
"line"
,
self
.
configuration
[
"instrument_resolution"
][
"
frequencies
"
],
units
=
'
THz
'
)
self
.
_outputData
.
add
(
"
frequency
_window"
,
"line"
,
self
.
_instrResolution
[
"
frequency
_window"
],
axis
=
"
frequency
"
,
units
=
"au"
)
self
.
_outputData
.
add
(
"
omega
"
,
"line"
,
self
.
configuration
[
"instrument_resolution"
][
"
omega
"
],
units
=
'
rad/ps
'
)
self
.
_outputData
.
add
(
"
omega
_window"
,
"line"
,
self
.
_instrResolution
[
"
omega
_window"
],
axis
=
"
omega
"
,
units
=
"au"
)
for
element
in
self
.
configuration
[
'atom_selection'
][
'unique_names'
]:
self
.
_outputData
.
add
(
"f(q,t)_%s"
%
element
,
"surface"
,
(
self
.
_nQShells
,
self
.
_nFrames
),
axis
=
"q|time
s
"
,
units
=
"au"
)
self
.
_outputData
.
add
(
"s(q,f)_%s"
%
element
,
"surface"
,
(
self
.
_nQShells
,
self
.
_n
Frequencie
s
),
axis
=
"q|
frequency
"
,
units
=
"nm2/ps"
)
self
.
_outputData
.
add
(
"f(q,t)_%s"
%
element
,
"surface"
,
(
self
.
_nQShells
,
self
.
_nFrames
),
axis
=
"q|time"
,
units
=
"au"
)
self
.
_outputData
.
add
(
"s(q,f)_%s"
%
element
,
"surface"
,
(
self
.
_nQShells
,
self
.
_n
Omega
s
),
axis
=
"q|
omega
"
,
units
=
"nm2/ps"
)
self
.
_outputData
.
add
(
"f(q,t)_total"
,
"surface"
,(
self
.
_nQShells
,
self
.
_nFrames
),
axis
=
"q|time
s
"
,
units
=
"au"
)
self
.
_outputData
.
add
(
"s(q,f)_total"
,
"surface"
,(
self
.
_nQShells
,
self
.
_n
Frequencie
s
),
axis
=
"q|
frequency
"
,
units
=
"nm2/ps"
)
self
.
_outputData
.
add
(
"f(q,t)_total"
,
"surface"
,(
self
.
_nQShells
,
self
.
_nFrames
),
axis
=
"q|time"
,
units
=
"au"
)
self
.
_outputData
.
add
(
"s(q,f)_total"
,
"surface"
,(
self
.
_nQShells
,
self
.
_n
Omega
s
),
axis
=
"q|
omega
"
,
units
=
"nm2/ps"
)
def
run_step
(
self
,
index
):
"""
...
...
MDANSE/Framework/Jobs/IJob.py
View file @
b6892c0b
...
...
@@ -515,7 +515,7 @@ class %s(IJob):
self.numberOfSteps = self.configuration['frames']['number']
# Create an output data for the selected frames.
self._outputData.add("time
s
", "line", self.configuration['frames']['time'], units='ps')
self._outputData.add("time", "line", self.configuration['frames']['time'], units='ps')
def run_step(self, index):
...
...
MDANSE/Framework/Jobs/McStasVirtualInstrument.py
View file @
b6892c0b
...
...
@@ -79,11 +79,11 @@ class McStasVirtualInstrument(IJob):
settings
[
'frames'
]
=
(
'frames'
,
{
"dependencies"
:{
'trajectory'
:
'trajectory'
}})
settings
[
'sample_coh'
]
=
(
'netcdf_input_file'
,
{
"widget"
:
'input_file'
,
"label"
:
'MDANSE Coherent Structure Factor'
,
"variables"
:[
'q'
,
'
frequency
'
,
's(q,f)_total'
],
"variables"
:[
'q'
,
'
omega
'
,
's(q,f)_total'
],
'default'
:
os
.
path
.
join
(
'..'
,
'..'
,
'..'
,
'Data'
,
'NetCDF'
,
'dcsf_prot.nc'
)})
settings
[
'sample_inc'
]
=
(
'netcdf_input_file'
,
{
"widget"
:
'input_file'
,
"label"
:
'MDANSE Incoherent Structure Factor'
,
"variables"
:[
'q'
,
'
frequency
'
,
's(q,f)_total'
],
"variables"
:[
'q'
,
'
omega
'
,
's(q,f)_total'
],