Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
nomad-lab
analytics-toolkit-tutorials
Commits
9b3c4953
Commit
9b3c4953
authored
Mar 16, 2017
by
Bieniek, Bjoern (biebj)
Browse files
Errobars: Update, loads faster.
parent
67693845
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
beaker-notebooks/errorbars_html.bkr
View file @
9b3c4953
This diff is collapsed.
Click to expand it.
example-data/errorbars/error_bar_convergence_VASP_170223.db
0 → 100644
View file @
9b3c4953
File added
example-data/errorbars/error_bar_monomers.json
View file @
9b3c4953
This diff is collapsed.
Click to expand it.
example-data/errorbars/errorbar_base.py
0 → 100644
View file @
9b3c4953
from
numpy
import
zeros
,
int32
,
unique
,
genfromtxt
,
sort
,
argsort
,
arange
,
\
append
,
array
from
ase
import
Atom
from
ase.db
import
connect
from
ase.atoms
import
string2symbols
def
get_data
(
con
,
name_dict
,
Z
,
code
,
category
,
keys
,
recommended_VASP
,
name_dict_monos_gpaw
,
name_dict_bins_gpaw
):
"""Function for obtaining the data from the databases for each code
Parameters:
con: The database
name_dict: dict
The dictionary for el. solid/binaries
Z: array like
atomic numbers for el. solids/binaries
code: str
DFT-code
category: str
code specific category string
keys: code specific parameters
"""
N_monos
=
len
(
name_dict
)
data
=
zeros
(
N_monos
)
if
code
==
'VASP'
:
rows
=
con
.
select
(
selection
=
[(
'category='
+
category
),
(
'precision='
+
keys
[
0
]),
(
'k_point_density='
+
str
(
keys
[
1
])),
(
'functional='
+
keys
[
2
])])
# For VASP we have to select the recommended Pseudo-Potential:
for
row
in
rows
:
if
category
.
find
(
'binaries'
)
==
0
:
A
=
unique
(
row
.
numbers
)[
0
]
-
1
B
=
unique
(
row
.
numbers
)[
1
]
-
1
rec_POT
=
(
'POTCAR'
+
recommended_VASP
[
A
,
1
].
replace
(
'POTCAR'
,
''
)
+
recommended_VASP
[
B
,
1
].
replace
(
'POTCAR'
,
''
))
data_POT
=
row
.
potcar
.
replace
(
'_h'
,
''
)
rec_POT
=
rec_POT
.
replace
(
'_3'
,
''
)
rec_POT
=
rec_POT
.
replace
(
'_2'
,
''
)
else
:
rec_POT
=
recommended_VASP
[
Z
[
name_dict
[
row
.
name
]]
-
1
,
1
]
data_POT
=
row
.
potcar
if
data_POT
==
rec_POT
:
data
[
name_dict
[
row
.
name
]]
=
row
.
total_energy
elif
code
==
'FHI-aims'
:
rows
=
con
.
select
(
selection
=
[(
'category='
+
category
),
(
'basis_set='
+
keys
[
0
]),
(
'k_point_density='
+
str
(
keys
[
1
])),
(
'functional='
+
keys
[
2
]),
(
'tiers='
+
keys
[
3
]),
(
'relativistic_treatment='
+
keys
[
4
])])
for
row
in
rows
:
data
[
name_dict
[
row
.
name
]]
=
row
.
total_energy
elif
code
==
'exciting'
:
rows
=
con
.
select
(
selection
=
[(
'category='
+
category
),
(
'k_point_density='
+
str
(
keys
[
0
]))])
for
row
in
rows
:
data
[
name_dict
[
row
.
name
]]
=
row
.
total_energy
elif
code
==
'GPAW'
:
rows
=
con
.
select
(
selection
=
[(
'category='
+
category
),
(
'ecut='
+
str
(
keys
[
0
])),
(
'k_point_density='
+
str
(
keys
[
1
]))])
# Mapping from formula to system name
for
row
in
rows
:
if
category
.
find
(
'binaries'
)
==
0
:
data
[
name_dict
[
name_dict_bins_gpaw
[
row
.
formula
]]]
=
row
.
energy
else
:
data
[
name_dict
[
name_dict_monos_gpaw
[
row
.
formula
]]]
=
row
.
energy
return
data
def
get_keys
(
code
,
prec
,
kpt
,
xc
,
tiers
,
rel
):
if
code
==
'VASP'
:
keys
=
[
prec
,
str
(
kpt
),
xc
,
tiers
]
ref_keys
=
[
xc
]
elif
code
==
'FHI-aims'
:
keys
=
[
prec
,
str
(
kpt
),
xc
,
tiers
,
rel
]
ref_keys
=
[
xc
,
rel
]
elif
code
==
'exciting'
:
keys
=
[
str
(
kpt
)]
ref_keys
=
[
xc
]
elif
code
==
'GPAW'
:
keys
=
[
prec
,
str
(
kpt
)]
ref_keys
=
[
xc
]
return
keys
,
ref_keys
def
get_xy
(
Z
,
N
,
data_ref
,
data
):
plot_x
=
sort
(
Z
)
plot_y
=
((
data_ref
-
data
)
/
N
)[
argsort
(
Z
)]
nonzero
=
((
data
!=
0
)
*
(
data_ref
!=
0
))[
argsort
(
Z
)]
plot_x
=
plot_x
[
nonzero
]
plot_y
=
plot_y
[
nonzero
]
#print(plot_x[abs(plot_y)>0.001])
return
plot_x
,
abs
(
plot_y
)
def
get_xy_predict
(
N
,
data_ref
,
data
):
plot_x
=
((
data
)
/
N
)
plot_y
=
data_ref
/
N
nonzero
=
(
plot_y
!=
0
)
*
(
plot_x
!=
0
)
plot_x
=
plot_x
[
nonzero
]
plot_y
=
plot_y
[
nonzero
]
#print(plot_x[abs(plot_y)>0.001])
return
abs
(
plot_x
),
abs
(
plot_y
)
def
get_binary_error_from_solids
(
error
,
binaries_to_monos_min
,
N_bins_min
,
binaries_to_monos_max
,
N_bins_max
,
pred
):
error_A
=
error
[
binaries_to_monos_min
]
error_B
=
error
[
binaries_to_monos_max
]
N_A
=
N_bins_min
N_B
=
N_bins_max
N_AB
=
N_A
+
N_B
if
pred
==
'1'
:
pred_error
=
(
error_A
*
N_A
+
error_B
*
N_B
)
rel_pred_error
=
pred_error
/
N_AB
elif
pred
==
'2'
:
pred_error
=
(
error_A
*
N_A
+
error_B
*
N_B
)
rel_pred_error
=
pred_error
/
N_AB
return
pred_error
#, rel_pred_error
def
do_plot
(
fig
,
ax
,
Z
,
N
,
data_ref
,
data
,
lab
):
plot_x
=
sort
(
Z
)
plot_y
=
((
data_ref
-
data
)
/
N
)[
argsort
(
Z
)]
nonzero
=
plot_y
!=
0
plot_x
=
plot_x
[
nonzero
]
plot_y
=
plot_y
[
nonzero
]
#print(plot_x[abs(plot_y)>0.001])
ax
.
semilogy
(
plot_x
,
abs
(
plot_y
),
'o'
,
label
=
lab
)
ax
.
legend
(
numpoints
=
1
,
loc
=
4
,
fontsize
=
8
)
fig
.
canvas
.
draw_idle
()
def
do_plot_predict
(
fig
,
ax
,
N
,
data_ref
,
data
,
lab
):
plot_x
=
((
data
)
/
N
)
plot_y
=
data_ref
/
N
nonzero
=
(
plot_y
!=
0
)
*
(
plot_x
!=
0
)
plot_x
=
plot_x
[
nonzero
]
plot_y
=
plot_y
[
nonzero
]
#print(plot_x[abs(plot_y)>0.001])
ax
.
loglog
(
abs
(
plot_x
),
abs
(
plot_y
),
'o'
,
label
=
lab
)
ax
.
plot
(
ax
.
get_xlim
(),
ax
.
get_xlim
(),
'-k'
)
ax
.
legend
(
numpoints
=
1
,
loc
=
4
,
fontsize
=
8
)
fig
.
canvas
.
draw_idle
()
def
get_xy
(
Z
,
N
,
data_ref
,
data
):
plot_x
=
sort
(
Z
)
plot_y
=
((
data_ref
-
data
)
/
N
)[
argsort
(
Z
)]
nonzero
=
plot_y
!=
0
plot_x
=
plot_x
#[nonzero]
plot_y
=
plot_y
#[nonzero]
#print(plot_x[abs(plot_y)>0.001])
return
plot_x
,
abs
(
plot_y
)
def
get_xy_predict
(
N
,
data_ref
,
data
):
plot_x
=
((
data
)
/
N
)
plot_y
=
data_ref
/
N
nonzero
=
(
plot_y
!=
0
)
*
(
plot_x
!=
0
)
plot_x
=
plot_x
[
nonzero
]
plot_y
=
plot_y
[
nonzero
]
#print(plot_x[abs(plot_y)>0.001])
return
abs
(
plot_x
),
abs
(
plot_y
)
def
get_xy_Ecoh
(
Z
,
data_monos
,
data_bins
,
zeroinds
,
binaries_to_monos_min
,
binaries_to_monos_max
,
N_bins_min
,
N_bins_max
):
error_A
=
data_monos
[
binaries_to_monos_min
]
error_B
=
data_monos
[
binaries_to_monos_max
]
N_A
=
N_bins_min
N_B
=
N_bins_max
N_AB
=
N_A
+
N_B
plot_x
=
Z
[
zeroinds
]
plot_y
=
((
data_bins
)[
zeroinds
]
-
(
error_A
*
N_A
+
error_B
*
N_B
)[
zeroinds
])
/
N_AB
[
zeroinds
]
return
plot_x
,
plot_y
def
get_mono_ind
(
formula
,
name_dict_monos
):
symbols
=
string2symbols
(
formula
)
ind
=
zeros
(
0
,
dtype
=
'int32'
)
N_f
=
len
(
symbols
)
notinset
=
False
for
s
in
symbols
:
at
=
Atom
(
s
)
if
at
.
number
<
10
:
try
:
ind
=
append
(
ind
,
name_dict_monos
[
'0'
+
str
(
at
.
number
)
+
'_'
+
s
])
except
KeyError
:
print
(
"Element "
+
s
+
" is not in the set of elementary solids."
)
notinset
=
True
break
else
:
try
:
ind
=
append
(
ind
,
name_dict_monos
[
str
(
at
.
number
)
+
'_'
+
s
])
except
KeyError
:
print
(
"Element "
+
s
+
" is not in the set of elementary solids."
)
notinset
=
True
break
return
N_f
,
ind
,
notinset
\ No newline at end of file
example-data/errorbars/errorbar_reference.json
0 → 100644
View file @
9b3c4953
This diff is collapsed.
Click to expand it.
example-data/errorbars/recommended_POTCAR.dat
View file @
9b3c4953
H POTCAR 250 1
He POTCAR 479 2
Li POTCAR 499 3
Li POTCAR
_sv
499 3
Be POTCAR 248 2
B POTCAR 319 3
C POTCAR 400 4
...
...
@@ -29,7 +29,7 @@ Ni POTCAR 270 10
Cu POTCAR 295 11
Zn POTCAR 277 12
Ga POTCAR_d 283 13
Ge POTCAR 310 14
Ge POTCAR
_d
310 14
As POTCAR 209 5
Se POTCAR 212 6
Br POTCAR 216 7
...
...
@@ -46,7 +46,7 @@ Rh POTCAR_pv 247 15
Pd POTCAR 251 10
Ag POTCAR 250 11
Cd POTCAR 274 12
In POTCAR 239 13
In POTCAR
_d
239 13
Sn POTCAR_d 241 14
Sb POTCAR 172 5
Te POTCAR 175 6
...
...
@@ -71,7 +71,7 @@ Yb POTCAR_2 113 8
Lu POTCAR_3 155 9
Hf POTCAR_pv 220 10
Ta POTCAR_pv 224 11
W POTCAR 223 12
W POTCAR
_sv
223 12
Re POTCAR 226 7
Os POTCAR 228 8
Ir POTCAR 211 9
...
...
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