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
0fc54155
Commit
0fc54155
authored
Nov 06, 2018
by
Gonzalez, Miguel
Committed by
Remi Perenon
Jan 23, 2019
Browse files
Debugging and modifying output variables
parent
f496e99d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Src/Framework/Jobs/NeutronDynamicTotalStructureFactor.py
View file @
0fc54155
...
...
@@ -101,26 +101,24 @@ class DynamicTotalStructureFactor(IJob):
self
.
_indexesPerElement
=
self
.
configuration
[
'atom_selection'
].
get_indexes
()
for
element
in
self
.
configuration
[
'atom_selection'
][
'unique_names'
]:
self
.
_outputData
.
add
(
"f
_inc
(q,t)_%s"
%
element
,
"surface"
,
(
nQShells
,
self
.
_nFrames
),
axis
=
"q|time"
,
units
=
"au"
)
self
.
_outputData
.
add
(
"
f_tot(q,t)
_%s"
%
element
,
"surface"
,
(
nQShells
,
self
.
_n
Frame
s
),
axis
=
"q|
time
"
,
units
=
"
au
"
)
self
.
_outputData
.
add
(
"
s_inc(q,f)
_%s"
%
element
,
"surface"
,
(
nQShells
,
self
.
_n
Omega
s
),
axis
=
"q|
omega
"
,
units
=
"
nm2/ps
"
)
self
.
_outputData
.
add
(
"s
_tot
(q,f)_%s"
%
element
,
"surface"
,
(
nQShells
,
self
.
_nOmegas
),
axis
=
"q|omega"
,
units
=
"nm2/ps"
)
self
.
_outputData
.
add
(
"f(q,t)_
inc_
%s"
%
element
,
"surface"
,
(
nQShells
,
self
.
_nFrames
),
axis
=
"q|time"
,
units
=
"au"
)
self
.
_outputData
.
add
(
"
s(q,f)_inc
_%s"
%
element
,
"surface"
,
(
nQShells
,
self
.
_n
Omega
s
),
axis
=
"q|
omega
"
,
units
=
"
nm2/ps
"
)
self
.
_outputData
.
add
(
"
f(q,t)_inc_weighted
_%s"
%
element
,
"surface"
,
(
nQShells
,
self
.
_n
Frame
s
),
axis
=
"q|
time
"
,
units
=
"
au
"
)
self
.
_outputData
.
add
(
"s(q,f)_
inc_weighted_
%s"
%
element
,
"surface"
,
(
nQShells
,
self
.
_nOmegas
),
axis
=
"q|omega"
,
units
=
"nm2/ps"
)
for
pair
in
self
.
_elementsPairs
:
self
.
_outputData
.
add
(
"f_coh(q,t)_%s%s"
%
pair
,
"surface"
,
(
nQShells
,
self
.
_nFrames
),
axis
=
"q|time"
,
units
=
"au"
)
self
.
_outputData
.
add
(
"s_coh(q,f)_%s%s"
%
pair
,
"surface"
,
(
nQShells
,
self
.
_nOmegas
),
axis
=
"q|omega"
,
units
=
"nm2/ps"
)
self
.
_outputData
.
add
(
"f_coh(q,t)_total"
,
"surface"
,
(
nQShells
,
self
.
_nFrames
),
axis
=
"q|time"
,
units
=
"au"
)
self
.
_outputData
.
add
(
"f_inc(q,t)_total"
,
"surface"
,
(
nQShells
,
self
.
_nFrames
),
axis
=
"q|time"
,
units
=
"au"
)
self
.
_outputData
.
add
(
"f_coh_weighted(q,t)_total"
,
"surface"
,
(
nQShells
,
self
.
_nFrames
),
axis
=
"q|time"
,
units
=
"au"
)
self
.
_outputData
.
add
(
"f_inc_weighted(q,t)_total"
,
"surface"
,
(
nQShells
,
self
.
_nFrames
),
axis
=
"q|time"
,
units
=
"au"
)
self
.
_outputData
.
add
(
"f_tot(q,t)_total"
,
"surface"
,
(
nQShells
,
self
.
_nFrames
),
axis
=
"q|time"
,
units
=
"au"
)
self
.
_outputData
.
add
(
"s_coh(q,f)_total"
,
"surface"
,
(
nQShells
,
self
.
_nOmegas
),
axis
=
"q|omega"
,
units
=
"nm2/ps"
)
self
.
_outputData
.
add
(
"s_inc(q,f)_total"
,
"surface"
,
(
nQShells
,
self
.
_nOmegas
),
axis
=
"q|omega"
,
units
=
"nm2/ps"
)
self
.
_outputData
.
add
(
"s_coh_weighted(q,f)_total"
,
"surface"
,
(
nQShells
,
self
.
_nOmegas
),
axis
=
"q|omega"
,
units
=
"nm2/ps"
)
self
.
_outputData
.
add
(
"s_inc_weighted(q,f)_total"
,
"surface"
,
(
nQShells
,
self
.
_nOmegas
),
axis
=
"q|omega"
,
units
=
"nm2/ps"
)
self
.
_outputData
.
add
(
"s_tot(q,f)_total"
,
"surface"
,
(
nQShells
,
self
.
_nOmegas
),
axis
=
"q|omega"
,
units
=
"nm2/ps"
)
self
.
_outputData
.
add
(
"f(q,t)_coh_%s%s"
%
pair
,
"surface"
,
(
nQShells
,
self
.
_nFrames
),
axis
=
"q|time"
,
units
=
"au"
)
self
.
_outputData
.
add
(
"s(q,f)_coh_%s%s"
%
pair
,
"surface"
,
(
nQShells
,
self
.
_nOmegas
),
axis
=
"q|omega"
,
units
=
"nm2/ps"
)
self
.
_outputData
.
add
(
"f(q,t)_coh_weighted_%s%s"
%
pair
,
"surface"
,
(
nQShells
,
self
.
_nFrames
),
axis
=
"q|time"
,
units
=
"au"
)
self
.
_outputData
.
add
(
"s(q,f)_coh_weighted_%s%s"
%
pair
,
"surface"
,
(
nQShells
,
self
.
_nOmegas
),
axis
=
"q|omega"
,
units
=
"nm2/ps"
)
self
.
_outputData
.
add
(
"f(q,t)_coh_total"
,
"surface"
,
(
nQShells
,
self
.
_nFrames
),
axis
=
"q|time"
,
units
=
"au"
)
self
.
_outputData
.
add
(
"f(q,t)_inc_total"
,
"surface"
,
(
nQShells
,
self
.
_nFrames
),
axis
=
"q|time"
,
units
=
"au"
)
self
.
_outputData
.
add
(
"f(q,t)_total"
,
"surface"
,
(
nQShells
,
self
.
_nFrames
),
axis
=
"q|time"
,
units
=
"au"
)
self
.
_outputData
.
add
(
"s(q,f)_coh_total"
,
"surface"
,
(
nQShells
,
self
.
_nOmegas
),
axis
=
"q|omega"
,
units
=
"nm2/ps"
)
self
.
_outputData
.
add
(
"s(q,f)_inc_total"
,
"surface"
,
(
nQShells
,
self
.
_nOmegas
),
axis
=
"q|omega"
,
units
=
"nm2/ps"
)
self
.
_outputData
.
add
(
"s(q,f)_total"
,
"surface"
,
(
nQShells
,
self
.
_nOmegas
),
axis
=
"q|omega"
,
units
=
"nm2/ps"
)
def
run_step
(
self
,
index
):
"""
...
...
@@ -199,10 +197,10 @@ class DynamicTotalStructureFactor(IJob):
for
pair
in
self
.
_elementsPairs
:
corr
=
correlation
(
rho
[
pair
[
0
]],
rho
[
pair
[
1
]],
average
=
1
)
self
.
_outputData
[
"f
_coh
(q,t)_%s%s"
%
pair
][
index
,:]
+=
corr
self
.
_outputData
[
"f(q,t)_
coh_
%s%s"
%
pair
][
index
,:]
+=
corr
for
k
,
v
in
disf
.
items
():
self
.
_outputData
[
"f
_inc
(q,t)_%s"
%
k
][
index
,:]
+=
v
self
.
_outputData
[
"f(q,t)_
inc_
%s"
%
k
][
index
,:]
+=
v
def
finalize
(
self
):
"""
...
...
@@ -214,44 +212,52 @@ class DynamicTotalStructureFactor(IJob):
nTotalAtoms
=
0
for
val
in
nAtomsPerElement
.
values
():
nTotalAtoms
+=
val
# Compute coherent functions and structure factor
for
pair
in
self
.
_elementsPairs
:
b
_coh1
=
ELEMENTS
[
pair
[
0
],
"b_coherent"
]
b
_coh2
=
ELEMENTS
[
pair
[
1
],
"b_coherent"
]
b
i
=
ELEMENTS
[
pair
[
0
],
"b_coherent"
]
b
j
=
ELEMENTS
[
pair
[
1
],
"b_coherent"
]
ni
=
nAtomsPerElement
[
pair
[
0
]]
nj
=
nAtomsPerElement
[
pair
[
1
]]
ci
=
float
(
ni
)
/
nTotalAtoms
cj
=
float
(
n
i
)
/
nTotalAtoms
cj
=
float
(
n
j
)
/
nTotalAtoms
self
.
_outputData
[
"f
_coh
(q,t)_%s%s"
%
pair
][:]
/=
numpy
.
sqrt
(
ni
*
nj
)
self
.
_outputData
[
"s
_coh
(q,f)_%s%s"
%
pair
][:]
=
get_spectrum
(
self
.
_outputData
[
"f
_coh
(q,t)_%s%s"
%
pair
],
self
.
_outputData
[
"f(q,t)_
coh_
%s%s"
%
pair
][:]
/=
numpy
.
sqrt
(
ni
*
nj
)
self
.
_outputData
[
"s(q,f)_
coh_
%s%s"
%
pair
][:]
=
get_spectrum
(
self
.
_outputData
[
"f(q,t)_
coh_
%s%s"
%
pair
],
self
.
configuration
[
"instrument_resolution"
][
"time_window"
],
self
.
configuration
[
"instrument_resolution"
][
"time_step"
],
axis
=
1
)
self
.
_outputData
[
"f_coh_weighted(q,t)_total"
][:]
+=
self
.
_outputData
[
"f_coh(q,t)_%s%s"
%
pair
][:]
*
numpy
.
sqrt
(
ci
*
cj
)
*
b_coh1
*
b_coh2
self
.
_outputData
[
"s_coh_weighted(q,f)_total"
][:]
+=
self
.
_outputData
[
"s_coh(q,f)_%s%s"
%
pair
][:]
*
numpy
.
sqrt
(
ci
*
cj
)
*
b_coh1
*
b_coh2
self
.
_outputData
[
"f(q,t)_coh_weighted_%s%s"
%
pair
][:]
=
self
.
_outputData
[
"f(q,t)_coh_%s%s"
%
pair
][:]
*
numpy
.
sqrt
(
ci
*
cj
)
*
bi
*
bj
self
.
_outputData
[
"s(q,f)_coh_weighted_%s%s"
%
pair
][:]
=
self
.
_outputData
[
"s(q,f)_coh_%s%s"
%
pair
][:]
*
numpy
.
sqrt
(
ci
*
cj
)
*
bi
*
bj
self
.
_outputData
[
"f(q,t)_coh_total"
][:]
+=
self
.
_outputData
[
"f(q,t)_coh_weighted_%s%s"
%
pair
][:]
self
.
_outputData
[
"s(q,f)_coh_total"
][:]
+=
self
.
_outputData
[
"s(q,f)_coh_weighted_%s%s"
%
pair
][:]
# Compute incoherent functions and structure factor
for
element
,
ni
in
nAtomsPerElement
.
items
():
b
_inc
=
ELEMENTS
[
element
,
"b_incoherent"
]
b
i
=
ELEMENTS
[
element
,
"b_incoherent
2
"
]
ni
=
nAtomsPerElement
[
element
]
ci
=
float
(
ni
)
/
nTotalAtoms
self
.
_outputData
[
"f
_inc
(q,t)_%s"
%
element
][:]
/=
ni
self
.
_outputData
[
"s
_inc
(q,f)_%s"
%
element
][:]
=
get_spectrum
(
self
.
_outputData
[
"f
_inc
(q,t)_%s"
%
element
],
self
.
_outputData
[
"f(q,t)_
inc_
%s"
%
element
][:]
/=
ni
self
.
_outputData
[
"s(q,f)_
inc_
%s"
%
element
][:]
=
get_spectrum
(
self
.
_outputData
[
"f(q,t)_
inc_
%s"
%
element
],
self
.
configuration
[
"instrument_resolution"
][
"time_window"
],
self
.
configuration
[
"instrument_resolution"
][
"time_step"
],
axis
=
1
)
self
.
_outputData
[
"f_inc_weighted(q,t)_total"
][:]
+=
self
.
_outputData
[
"f_inc(q,t)_%s"
%
element
][:]
*
ci
*
b_inc
**
2
self
.
_outputData
[
"s_inc_weighted(q,f)_total"
][:]
+=
self
.
_outputData
[
"s_inc(q,f)_%s"
%
element
][:]
*
ci
*
b_inc
**
2
self
.
_outputData
[
"f(q,t)_inc_weighted_%s"
%
element
][:]
=
self
.
_outputData
[
"f(q,t)_inc_%s"
%
element
][:]
*
ci
*
bi
self
.
_outputData
[
"s(q,f)_inc_weighted_%s"
%
element
][:]
=
self
.
_outputData
[
"s(q,f)_inc_%s"
%
element
][:]
*
ci
*
bi
self
.
_outputData
[
"f(q,t)_inc_total"
][:]
+=
self
.
_outputData
[
"f(q,t)_inc_weighted_%s"
%
element
][:]
self
.
_outputData
[
"s(q,f)_inc_total"
][:]
+=
self
.
_outputData
[
"s(q,f)_inc_weighted_%s"
%
element
][:]
# Compute total
sum
self
.
_outputData
[
"f
_tot
(q,t)_total"
][:]
=
self
.
_outputData
[
"f
_coh_weighted
(q,t)_total"
][:]
+
self
.
_outputData
[
"f
_inc_weighted
(q,t)_total"
][:]
self
.
_outputData
[
"s
_tot
(q,f)_total"
][:]
=
self
.
_outputData
[
"s
_coh_weighted
(q,f)_total"
][:]
+
self
.
_outputData
[
"s
_inc_weighted
(q,f)_total"
][:]
# Compute total
F(Q,t) = inc + coh
self
.
_outputData
[
"f(q,t)_total"
][:]
=
self
.
_outputData
[
"f(q,t)_
coh_
total"
][:]
+
self
.
_outputData
[
"f(q,t)_
inc_
total"
][:]
self
.
_outputData
[
"s(q,f)_total"
][:]
=
self
.
_outputData
[
"s(q,f)_
coh_
total"
][:]
+
self
.
_outputData
[
"s(q,f)_
inc_
total"
][:]
#
self
.
_outputData
.
write
(
self
.
configuration
[
'output_files'
][
'root'
],
self
.
configuration
[
'output_files'
][
'formats'
],
self
.
_info
)
self
.
configuration
[
'trajectory'
][
'instance'
].
close
()
REGISTRY
[
'ndtsf'
]
=
NeutronDynamicTotalStructureFactor
\ No newline at end of file
REGISTRY
[
'ndtsf'
]
=
NeutronDynamicTotalStructureFactor
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment