Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
frtrglib
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Valentin Bruch
frtrglib
Commits
0f07bb6f
Commit
0f07bb6f
authored
Jun 21, 2022
by
Valentin Bruch
Browse files
Options
Downloads
Patches
Plain Diff
bug fixes, documentation in data_management
parent
e5ac8e89
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
data_management.py
+51
-16
51 additions, 16 deletions
data_management.py
gen_data.py
+6
-4
6 additions, 4 deletions
gen_data.py
with
57 additions
and
20 deletions
data_management.py
+
51
−
16
View file @
0f07bb6f
"""
"""
Data management for FRTRG data based on pytables
Kondo FRTRG, data management
Idea:
This file contains functions and classes to manage data generated using the
* Data + Metadata are stored in H5F files.
kondo module.
* A single file can be any logical unit. An arbitrary number of files can be created.
* Metadata are partially stored in a database for simple access
General concepts:
* a file
"
filename.lock
"
is created before writing to a file.
* All metadata are stored in an SQL database.
* Floquet matrices are stored in H5F files.
Copyright 2022 Valentin Bruch
* Each H5F file can contain multiple data points. Data points can be added to
H5F files.
* Each H5F file contains a table of metadata for the data points stored in
this file.
* Data points are identified in H5F files by a hash generated from their full
Floquet matrices at the end of the RG flow.
* The SQL database stores the directory, filename, and hash where the Floquet
matrices are stored.
Implementation:
* pandas for accessing the SQL database and managing the full table of metadata
* pytables for H5F files
* a file
"
filename.lock
"
is temporarily created when writing to a H5F file.
Copyright 2022 Valentin Bruch <valentin.bruch@rwth-aachen.de>
License: MIT
License: MIT
"""
"""
...
@@ -23,11 +37,24 @@ import random
...
@@ -23,11 +37,24 @@ import random
import
settings
import
settings
import
warnings
import
warnings
# We use hashs as identifiers for data points in H5F files. These hashs are
# often not valid python names, which causes a warning. We ignore this warning.
warnings
.
simplefilter
(
"
ignore
"
,
tb
.
NaturalNameWarning
)
warnings
.
simplefilter
(
"
ignore
"
,
tb
.
NaturalNameWarning
)
def
random_string
(
length
:
int
):
_to_char
=
lambda
x
:
chr
(
x
+
48
if
x
<
10
else
x
+
55
if
x
<
36
else
x
+
61
)
"""
random_string
=
lambda
n
:
''
.
join
(
_to_char
(
random
.
randint
(
0
,
61
))
for
i
in
range
(
n
))
Generate random strings of alphanumerical characters with given length.
"""
res
=
""
for
_
in
range
(
length
):
x
=
random
.
randint
(
0
,
61
)
if
x
<
10
:
res
+=
chr
(
x
+
48
)
elif
x
<
36
:
res
+=
chr
(
x
+
55
)
else
:
res
+=
chr
(
x
+
61
)
return
res
def
replace_all
(
string
:
str
,
replacements
:
dict
):
def
replace_all
(
string
:
str
,
replacements
:
dict
):
...
@@ -69,6 +96,7 @@ class KondoExport:
...
@@ -69,6 +96,7 @@ class KondoExport:
"""
"""
dictionary of metadata
dictionary of metadata
"""
"""
# Determine method
if
self
.
kondo
.
unitary_transformation
:
if
self
.
kondo
.
unitary_transformation
:
if
self
.
kondo
.
compact
==
2
:
if
self
.
kondo
.
compact
==
2
:
method
=
'
J-compact-2
'
method
=
'
J-compact-2
'
...
@@ -78,27 +106,29 @@ class KondoExport:
...
@@ -78,27 +106,29 @@ class KondoExport:
method
=
'
J
'
method
=
'
J
'
else
:
else
:
method
=
'
mu
'
method
=
'
mu
'
# Collect solver flags
solver_flags
=
0
solver_flags
=
0
try
:
try
:
if
self
.
kondo
.
simplified_initial_conditions
:
if
self
.
kondo
.
simplified_initial_conditions
:
solver_flags
|=
DataManager
.
SOLVER_FLAGS
[
"
simplified_initial_conditions
"
]
solver_flags
|=
DataManager
.
SOLVER_FLAGS
[
"
simplified_initial_conditions
"
]
except
AttributeError
:
except
AttributeError
:
pass
pass
for
(
key
,
value
)
in
kondo
.
settings
.
items
():
for
(
key
,
value
)
in
self
.
kondo
.
global_
settings
.
items
():
if
value
:
if
value
:
try
:
try
:
solver_flags
|=
DataManager
.
SOLVER_FLAGS
[
key
.
lower
()]
solver_flags
|=
DataManager
.
SOLVER_FLAGS
[
key
.
lower
()]
except
KeyError
:
except
KeyError
:
pass
pass
version
=
kondo
.
settings
[
"
VERSION
"
]
version
=
self
.
kondo
.
global_
settings
[
"
VERSION
"
]
return
dict
(
return
dict
(
hash
=
self
.
hash
,
hash
=
self
.
hash
,
omega
=
self
.
kondo
.
omega
,
omega
=
self
.
kondo
.
omega
,
energy
=
self
.
kondo
.
energy
,
energy
=
self
.
kondo
.
energy
,
version_major
=
version
[
0
],
version_major
=
version
[
0
],
version_minor
=
version
[
1
],
version_minor
=
version
[
1
],
lazy_inverse_factor
=
kondo
.
settings
[
"
LAZY_INVERSE_FACTOR
"
]
lazy_inverse_factor
=
self
.
kondo
.
global_
settings
[
"
LAZY_INVERSE_FACTOR
"
]
,
git_commit_count
=
version
[
2
],
git_commit_count
=
version
[
2
],
git_commit_id
=
version
[
3
],
git_commit_id
=
version
[
3
],
method
=
method
,
method
=
method
,
...
@@ -121,7 +151,12 @@ class KondoExport:
...
@@ -121,7 +151,12 @@ class KondoExport:
"""
"""
dictionary of main results: DC current, DC conductance, AC current (absolute value and phase)
dictionary of main results: DC current, DC conductance, AC current (absolute value and phase)
"""
"""
results
=
dict
(
dc_current
=
np
.
nan
,
dc_conductance
=
np
.
nan
,
ac_current_abs
=
np
.
nan
,
ac_current_phase
=
np
.
nan
)
results
=
dict
(
dc_current
=
np
.
nan
,
dc_conductance
=
np
.
nan
,
ac_current_abs
=
np
.
nan
,
ac_current_phase
=
np
.
nan
)
nmax
=
self
.
kondo
.
nmax
nmax
=
self
.
kondo
.
nmax
try
:
try
:
results
[
'
dc_current
'
]
=
self
.
kondo
.
gammaL
[
nmax
,
nmax
].
real
results
[
'
dc_current
'
]
=
self
.
kondo
.
gammaL
[
nmax
,
nmax
].
real
...
...
This diff is collapsed.
Click to expand it.
gen_data.py
+
6
−
4
View file @
0f07bb6f
...
@@ -15,7 +15,7 @@ import settings
...
@@ -15,7 +15,7 @@ import settings
import
numpy
as
np
import
numpy
as
np
def
gen_option_iter
(
steps
,
scales
,
**
options
):
def
gen_option_iter
(
steps
=
None
,
scales
=
None
,
**
options
):
"""
"""
Interpret given options to swipe over parameters.
Interpret given options to swipe over parameters.
...
@@ -46,9 +46,11 @@ def gen_option_iter(steps, scales, **options):
...
@@ -46,9 +46,11 @@ def gen_option_iter(steps, scales, **options):
options
.
pop
(
key
)
options
.
pop
(
key
)
steps
=
[
max_length
]
steps
=
[
max_length
]
else
:
else
:
if
isinstance
(
scales
,
str
):
if
scales
is
None
:
scales
=
len
(
steps
)
*
[
"
linear
"
]
elif
isinstance
(
scales
,
str
):
scales
=
len
(
steps
)
*
[
scales
]
scales
=
len
(
steps
)
*
[
scales
]
if
len
(
scales
)
==
1
:
el
if
len
(
scales
)
==
1
:
scales
*=
len
(
steps
)
scales
*=
len
(
steps
)
for
key
,
value
in
options
.
items
():
for
key
,
value
in
options
.
items
():
if
type
(
value
)
!=
list
or
key
==
"
fourier_coef
"
:
if
type
(
value
)
!=
list
or
key
==
"
fourier_coef
"
:
...
...
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