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
On Thursday, 7th July from 1 to 3 pm there will be a maintenance with a short downtime of GitLab.
Open sidebar
ift
NIFTy
Commits
c7ebdfce
Commit
c7ebdfce
authored
Jun 30, 2020
by
Philipp Arras
Browse files
Add possibility to turn off flexibility
parent
9b3d5b5b
Pipeline
#77535
passed with stages
in 13 minutes and 27 seconds
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
src/library/correlated_fields_simple.py
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
))
...
...
test/test_operators/test_correlated_fields.py
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
)
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