kmath dev-10

This commit is contained in:
Alexander Nozik 2021-05-16 22:45:12 +03:00
parent a1dea9cac9
commit 2f3e9357ff
2 changed files with 7 additions and 6 deletions

View File

@ -13,6 +13,7 @@ import space.kscience.kmath.functions.UnivariateFunction
import space.kscience.kmath.functions.value
import space.kscience.kmath.integration.GaussIntegrator
import space.kscience.kmath.integration.integrate
import space.kscience.kmath.integration.value
import space.kscience.kmath.misc.Symbol
import space.kscience.kmath.misc.symbol
import space.kscience.kmath.operations.DoubleField
@ -273,7 +274,7 @@ public class NumassTransmission(
val res = { x: Double ->
integrator.integrate(5.0..margin) { y ->
loss(x - y) * singleScatterFunction(y)
}
}.value
}
return res.cache(0.0..margin, 200)
@ -389,7 +390,7 @@ public class NumassTransmission(
val cutoff = 25.0
//caclulating lorentz integral analythically
val tailNorm = (atan((ionPos - cutoff) * 2.0 / ionW) + 0.5 * PI) * ionW / 2.0
val norm: Double = integrator.integrate(range = 0.0..cutoff, function = func) + tailNorm
val norm: Double = integrator.integrate(range = 0.0..cutoff, function = func).value + tailNorm
return { e -> func(e) / norm }
}

View File

@ -15,6 +15,7 @@ import inr.numass.models.sterile.NumassTransmission.Companion.trap
import ru.inr.mass.models.*
import space.kscience.kmath.expressions.derivative
import space.kscience.kmath.integration.integrate
import space.kscience.kmath.integration.integrator
import space.kscience.kmath.integration.value
import space.kscience.kmath.misc.Symbol
import space.kscience.kmath.operations.DoubleField
@ -91,7 +92,7 @@ public class SterileNeutrinoSpectrum(
// getHighDensityIntegrator()
// }
return DoubleField.integrate(u..eMax) { eIn ->
return DoubleField.integrator.integrate(u..eMax) { eIn ->
sumByFSS(eIn, sourceFunction, arguments) * transResFunction(eIn, u, arguments)
}.value ?: error("Integration failed")
}
@ -125,10 +126,9 @@ public class SterileNeutrinoSpectrum(
val integrand = { eOut: Double -> transFunc(eIn, eOut, arguments) * resolution(eOut, u, arguments) }
val border = u + 30
val firstPart = DoubleField.integrate(u..min(eIn, border), function = integrand).value
?: error("Integration failed")
val firstPart = DoubleField.integrator.integrate(u..min(eIn, border), function = integrand).value
val secondPart: Double = if (eIn > border) {
DoubleField.integrate(border..eIn, function = integrand).value ?: error("Integration failed")
DoubleField.integrator.integrate(border..eIn, function = integrand).value
} else {
0.0
}