Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
MDANSE
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Scientific Software
MDANSE
Commits
0fc54155
Commit
0fc54155
authored
6 years ago
by
Gonzalez, Miguel
Committed by
Remi Perenon
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Debugging and modifying output variables
parent
f496e99d
No related branches found
No related tags found
1 merge request
!42
Feature total structure factor
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Src/Framework/Jobs/NeutronDynamicTotalStructureFactor.py
+43
-37
43 additions, 37 deletions
Src/Framework/Jobs/NeutronDynamicTotalStructureFactor.py
with
43 additions
and
37 deletions
Src/Framework/Jobs/NeutronDynamicTotalStructureFactor.py
+
43
−
37
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
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment