Skip to content
Snippets Groups Projects
Commit 374675e9 authored by Philipp Arras's avatar Philipp Arras
Browse files

Support fields as amplitudes in correlated field

parent a25ec34e
Branches
Tags
1 merge request!367WIP: Normalized amplitudes pp
Pipeline #62511 passed
...@@ -19,13 +19,14 @@ from functools import reduce ...@@ -19,13 +19,14 @@ from functools import reduce
from operator import mul from operator import mul
from ..domain_tuple import DomainTuple from ..domain_tuple import DomainTuple
from ..field import Field
from ..operators.adder import Adder from ..operators.adder import Adder
from ..operators.contraction_operator import ContractionOperator from ..operators.contraction_operator import ContractionOperator
from ..operators.distributors import PowerDistributor from ..operators.distributors import PowerDistributor
from ..operators.harmonic_operators import HarmonicTransformOperator from ..operators.harmonic_operators import HarmonicTransformOperator
from ..operators.operator import Operator from ..operators.operator import Operator
from ..operators.simple_linear_operators import VdotOperator, ducktape from ..operators.simple_linear_operators import VdotOperator, ducktape
from ..sugar import full from ..sugar import full, makeOp
def CorrelatedField(target, amplitude_operator, name='xi', codomain=None): def CorrelatedField(target, amplitude_operator, name='xi', codomain=None):
...@@ -68,15 +69,23 @@ def CorrelatedField(target, amplitude_operator, name='xi', codomain=None): ...@@ -68,15 +69,23 @@ def CorrelatedField(target, amplitude_operator, name='xi', codomain=None):
codomain = tgt[0].get_default_codomain() codomain = tgt[0].get_default_codomain()
h_space = codomain h_space = codomain
ht = HarmonicTransformOperator(h_space, target=tgt[0]) ht = HarmonicTransformOperator(h_space, target=tgt[0])
p_space = amplitude_operator.target[0] if isinstance(amplitude_operator, Operator):
p_space = amplitude_operator.target[0]
elif isinstance(amplitude_operator, Field):
p_space = amplitude_operator.domain[0]
else:
raise TypeError
power_distributor = PowerDistributor(h_space, p_space) power_distributor = PowerDistributor(h_space, p_space)
A = power_distributor(amplitude_operator) A = power_distributor(amplitude_operator)
vol = h_space.scalar_dvol**-0.5 vol = h_space.scalar_dvol**-0.5
xi = ducktape(h_space, None, name)
# When doubling the resolution of `tgt` the value of the highest k-mode # When doubling the resolution of `tgt` the value of the highest k-mode
# will scale with a square root. `vol` cancels this effect such that the # will scale with a square root. `vol` cancels this effect such that the
# same power spectrum can be used for the spaces with the same volume, # same power spectrum can be used for the spaces with the same volume,
# different resolutions and the same object in them. # different resolutions and the same object in them.
return ht(vol*A*ducktape(h_space, None, name)) if isinstance(amplitude_operator, Field):
return ht(makeOp(A)@xi).scale(vol)
return ht(A*xi).scale(vol)
def MfCorrelatedField(target, amplitudes, name='xi'): def MfCorrelatedField(target, amplitudes, name='xi'):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment