Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
NIFTy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Monitor
Service Desk
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ift
NIFTy
Commits
c7ebdfce
Commit
c7ebdfce
authored
5 years ago
by
Philipp Arras
Browse files
Options
Downloads
Patches
Plain Diff
Add possibility to turn off flexibility
parent
9b3d5b5b
No related branches found
No related tags found
1 merge request
!555
No flexibility or asperity for simple correlated field maker
Pipeline
#77535
passed
5 years ago
Stage: build_docker
Stage: test
Stage: demo_runs
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/library/correlated_fields_simple.py
+26
-21
26 additions, 21 deletions
src/library/correlated_fields_simple.py
test/test_operators/test_correlated_fields.py
+24
-0
24 additions, 0 deletions
test/test_operators/test_correlated_fields.py
with
50 additions
and
21 deletions
src/library/correlated_fields_simple.py
+
26
−
21
View file @
c7ebdfce
...
...
@@ -52,40 +52,45 @@ class SimpleCorrelatedField(Operator):
if
len
(
kk
)
!=
2
:
raise
TypeError
for
kk
in
[
flexibility
,
asperity
]:
if
kk
is
None
or
len
(
kk
)
!
=
2
:
if
not
(
kk
is
None
or
len
(
kk
)
=
=
2
)
:
raise
TypeError
if
flexibility
is
None
and
asperity
is
not
None
:
raise
ValueError
fluct
=
LognormalTransform
(
*
fluctuations
,
prefix
+
'
fluctuations
'
,
0
)
flex
=
LognormalTransform
(
*
flexibility
,
prefix
+
'
flexibility
'
,
0
)
asp
=
LognormalTransform
(
*
asperity
,
prefix
+
'
asperity
'
,
0
)
avgsl
=
NormalTransform
(
*
loglogavgslope
,
prefix
+
'
loglogavgslope
'
,
0
)
zm
=
LognormalTransform
(
*
offset_std
,
prefix
+
'
zeromode
'
,
0
)
pspace
=
PowerSpace
(
harmonic_partner
)
twolog
=
_TwoLogIntegrations
(
pspace
)
expander
=
ContractionOperator
(
twolog
.
domain
,
0
).
adjoint
ps_expander
=
ContractionOperator
(
pspace
,
0
).
adjoint
vslope
=
makeOp
(
makeField
(
pspace
,
_relative_log_k_lengths
(
pspace
)))
slope
=
vslope
@
ps_expander
@
avgsl
a
=
slope
if
flexibility
is
not
None
:
flex
=
LognormalTransform
(
*
flexibility
,
prefix
+
'
flexibility
'
,
0
)
dom
=
twolog
.
domain
[
0
]
vflex
=
np
.
zeros
(
dom
.
shape
)
vasp
=
np
.
zeros
(
dom
.
shape
)
shift
=
np
.
ones
(
dom
.
shape
)
vflex
[
0
]
=
vflex
[
1
]
=
np
.
sqrt
(
_log_vol
(
pspace
))
vasp
[
0
]
=
1
shift
[
0
]
=
_log_vol
(
pspace
)
**
2
/
12.
vflex
=
makeOp
(
makeField
(
dom
,
vflex
))
vasp
=
makeOp
(
makeField
(
dom
,
vasp
))
shift
=
makeField
(
dom
,
shift
)
vslope
=
makeOp
(
makeField
(
pspace
,
_relative_log_k_lengths
(
pspace
)))
expander
=
ContractionOperator
(
twolog
.
domain
,
0
).
adjoint
ps_expander
=
ContractionOperator
(
pspace
,
0
).
adjoint
slope
=
vslope
@
ps_expander
@
avgsl
sig_flex
=
vflex
@
expander
@
flex
sig_asp
=
vasp
@
expander
@
asp
xi
=
ducktape
(
dom
,
None
,
prefix
+
'
spectrum
'
)
smooth
=
xi
*
sig_flex
*
(
Adder
(
shift
)
@
sig_asp
).
ptw
(
"
sqrt
"
)
smooth
=
_SlopeRemover
(
pspace
,
0
)
@
twolog
@
smooth
a
=
_Normalization
(
pspace
,
0
)
@
(
slope
+
smooth
)
if
asperity
is
None
:
raise
NotImplementedError
asp
=
LognormalTransform
(
*
asperity
,
prefix
+
'
asperity
'
,
0
)
vasp
=
np
.
zeros
(
dom
.
shape
)
vasp
[
0
]
=
1
vasp
=
makeOp
(
makeField
(
dom
,
vasp
))
sig_asp
=
vasp
@
expander
@
asp
shift
=
np
.
ones
(
dom
.
shape
)
shift
[
0
]
=
_log_vol
(
pspace
)
**
2
/
12.
shift
=
makeField
(
dom
,
shift
)
asp
=
(
Adder
(
shift
)
@
sig_asp
).
ptw
(
"
sqrt
"
)
a
=
a
+
_SlopeRemover
(
pspace
,
0
)
@
twolog
@
(
xi
*
sig_flex
*
asp
)
a
=
_Normalization
(
pspace
,
0
)
@
a
maskzm
=
np
.
ones
(
pspace
.
shape
)
maskzm
[
0
]
=
0
maskzm
=
makeOp
(
makeField
(
pspace
,
maskzm
))
...
...
This diff is collapsed.
Click to expand it.
test/test_operators/test_correlated_fields.py
+
24
−
0
View file @
c7ebdfce
...
...
@@ -171,3 +171,27 @@ def test_complicated_vs_simple(seed, domain):
op0
=
scf
.
amplitude
assert_
(
op0
.
domain
is
op1
.
domain
)
ift
.
extra
.
assert_allclose
(
op0
.
force
(
inp
),
op1
.
force
(
inp
))
@pmp
(
'
asperity
'
,
[
None
,
(
_posrand
(),
_posrand
())])
@pmp
(
'
flexibility
'
,
[
None
,
(
_posrand
(),
_posrand
())])
def
test_simple_without_asp_fluct
(
asperity
,
flexibility
):
domain
=
ift
.
RGSpace
((
4
,
4
),
(
0.123
,
0.4
))
offset_mean
=
_rand
()
offset_std
=
_posrand
(),
_posrand
()
fluctuations
=
_posrand
(),
_posrand
()
loglogavgslope
=
_posrand
(),
_posrand
()
prefix
=
'
foobar
'
hspace
=
domain
.
get_default_codomain
()
args
=
(
domain
,
offset_mean
,
offset_std
,
fluctuations
,
flexibility
,
asperity
,
loglogavgslope
,
prefix
,
hspace
)
if
asperity
is
not
None
and
flexibility
is
None
:
with
pytest
.
raises
(
ValueError
):
scf
=
ift
.
SimpleCorrelatedField
(
*
args
)
elif
asperity
is
None
and
flexibility
is
not
None
:
with
pytest
.
raises
(
NotImplementedError
):
scf
=
ift
.
SimpleCorrelatedField
(
*
args
)
else
:
scf
=
ift
.
SimpleCorrelatedField
(
*
args
)
inp
=
ift
.
from_random
(
scf
.
domain
)
ift
.
extra
.
check_operator
(
scf
,
inp
,
ntries
=
10
)
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