feat(tests): add trap and rear wall contribution graphs

This commit is contained in:
2025-04-03 14:44:03 +03:00
parent 73f615c51e
commit daca7ec262
2 changed files with 108 additions and 37 deletions

View File

@@ -0,0 +1,85 @@
package ru.inr.mass.scripts
import ru.inr.mass.models.*
import ru.inr.mass.models.NBkgSpectrum.Companion.bkg
import ru.inr.mass.models.NBkgSpectrum.Companion.norm
import ru.inr.mass.models.NumassBeta.e0
import ru.inr.mass.models.NumassBeta.mnu2
import ru.inr.mass.models.NumassBeta.msterile2
import ru.inr.mass.models.NumassBeta.u2
import ru.inr.mass.models.NumassTransmission.Companion.thickness
import ru.inr.mass.models.NumassTransmission.Companion.trap
import ru.inr.mass.workspace.buffer
import space.kscience.kmath.expressions.Symbol
import space.kscience.kmath.real.step
import space.kscience.plotly.*
import space.kscience.plotly.models.ScatterMode
fun main() {
val trapInterpolator = TrapInterpolator()
val range = 10000.0..18600.0 step 50.0
val args: Map<Symbol, Double> = mapOf(
norm to 231296.31435970013,
bkg to 1.156996613764463,
mnu2 to 0.0,
e0 to 18553.267180007213,
msterile2 to 16e6,
u2 to -0.006326658267906115,
thickness to 0.1,
trap to 0.0,
rearWall to 0.04192630322035539
)
val argsTrap1 = args.toMutableMap();
argsTrap1[trap] = 1.0
val argsTrap2 = args.toMutableMap();
argsTrap2[trap] = 2.0
val argsTrap3 = args.toMutableMap();
argsTrap3[trap] = 3.0
val spectrumC: NBkgSpectrum = CustomSterileNeutrinoSpectrum(
fss = null,
transmission = NumassTransmission(
trapFunc = { ei, ef, _ ->
val delta = ei - ef
trapInterpolator.value(ei, delta)
},
adjustX = false,
),
resolution = NumassResolution(1.7e-4, tailFunction = {
e,u -> adiabacity(e,u)
})
).withNBkg()
Plotly.page {
plot {
scatter {
name = "CustomSterileNeutrinoSpectrum (trap=${args[trap]})"
mode = ScatterMode.lines
x.buffer = range
y.numbers = x.doubles.map { spectrumC(it, args) }
}
listOf(argsTrap1, argsTrap2, argsTrap3).forEach { argsTrap ->
scatter {
name = "CustomSterileNeutrinoSpectrum (trap=${argsTrap[trap]})"
mode = ScatterMode.lines
x.buffer = range
y.numbers = x.doubles.map { spectrumC(it, argsTrap) }
}
}
layout {
title = "Compare Trap"
// yaxis.type = AxisType.log
}
}
}.makeFile()
println("HV\ttrap=${args[trap]}\ttrap=${argsTrap3[trap]}")
range.iterator().forEach {
println("${it}\t${spectrumC(it, args)}\t${spectrumC(it, argsTrap3)}")
}
}

View File

@@ -13,41 +13,27 @@ import ru.inr.mass.workspace.buffer
import space.kscience.kmath.expressions.Symbol
import space.kscience.kmath.real.step
import space.kscience.plotly.*
import space.kscience.plotly.models.AxisType
import space.kscience.plotly.models.ScatterMode
import kotlin.math.pow
fun main() {
val trapInterpolator = RearTrapInterpolator()
val range = 12000.0..17000.0 step 50.0
val spectrum: NBkgSpectrum = SterileNeutrinoSpectrum(
fss = null,
transmission = NumassTransmission(
trapFunc = { ei, ef, _ ->
val delta = ei - ef
trapInterpolator.value(ei, delta)
},
adjustX = false,
),
resolution = NumassResolution(1.7e-4, tailFunction = {
e,u -> adiabacity(e,u)
})
).withNBkg()
val trapInterpolator = TrapInterpolator()
val range = 10000.0..18600.0 step 50.0
val args: Map<Symbol, Double> = mapOf(
norm to 1.0,
bkg to 0.0,
norm to 231296.31435970013,
bkg to 1.156996613764463,
mnu2 to 0.0,
e0 to 18575.0,
msterile2 to 0000.0.pow(2),
u2 to 0e-2,
thickness to 0.0,
trap to 1.0,
rearWall to 0.02
e0 to 18553.267180007213,
msterile2 to 16e6,
u2 to -0.006326658267906115,
thickness to 0.1,
trap to 3.0,
rearWall to 0.0
)
val argsRWall = args.toMutableMap();
argsRWall[rearWall] = 0.04
val spectrumC: NBkgSpectrum = CustomSterileNeutrinoSpectrum(
fss = null,
@@ -64,28 +50,28 @@ fun main() {
).withNBkg()
Plotly.page {
plot {
scatter {
name = "SterileNeutrinoSpectrum"
name = "CustomSterileNeutrinoSpectrum (rearWall=${args[rearWall]})"
mode = ScatterMode.lines
x.buffer = range
y.numbers = x.doubles.map {
val value = spectrum(it, args)
// println("${it}\t${value}")
value
}
y.numbers = x.doubles.map { spectrumC(it, args) }
}
scatter {
name = "CustomSterileNeutrinoSpectrum"
name = "CustomSterileNeutrinoSpectrum (rearWall=${argsRWall[rearWall]})"
mode = ScatterMode.lines
x.buffer = range
y.numbers = x.doubles.map { wallStep(it) * 0.02 }
y.numbers = x.doubles.map { spectrumC(it, argsRWall) }
}
layout {
title = "Sterile neutrino spectrum"
yaxis.type = AxisType.log
title = "Compare Trap"
// yaxis.type = AxisType.log
}
}
}.makeFile()
println("HV\trearWall=${args[rearWall]}\trearWall=${argsRWall[rearWall]}")
range.iterator().forEach {
println("${it}\t${spectrumC(it, args)}\t${spectrumC(it, argsRWall)}")
}
}