Update build. Add cross-sections calculator
This commit is contained in:
parent
9795e1e3df
commit
7a2c1d448a
29
build.gradle
29
build.gradle
@ -1,29 +0,0 @@
|
||||
plugins {
|
||||
id "org.jetbrains.kotlin.jvm" version "1.4.10"
|
||||
id "application"
|
||||
}
|
||||
|
||||
group = 'ru.inr.mass'
|
||||
version = '1.0.0'
|
||||
|
||||
description = "Numass trapping simulation"
|
||||
|
||||
mainClassName = "ru.inr.mass.trapping.TrappingKt"
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile group: 'org.apache.commons', name: 'commons-math3', version: '3.6.1'
|
||||
|
||||
// https://mvnrepository.com/artifact/org.apache.commons/commons-rng-simple
|
||||
compile group: 'org.apache.commons', name: 'commons-rng-simple', version: '1.1'
|
||||
|
||||
testCompile group: 'junit', name: 'junit', version: '4.12'
|
||||
}
|
||||
|
||||
compileKotlin {
|
||||
kotlinOptions.jvmTarget = "1.8"
|
||||
}
|
||||
|
30
build.gradle.kts
Normal file
30
build.gradle.kts
Normal file
@ -0,0 +1,30 @@
|
||||
plugins {
|
||||
kotlin("jvm") version "1.4.10"
|
||||
application
|
||||
}
|
||||
|
||||
group = "ru.inr.mass"
|
||||
version = "1.1.0"
|
||||
|
||||
description = "Numass trapping simulation"
|
||||
application {
|
||||
mainClassName = "ru.inr.mass.trapping.MainKt"
|
||||
}
|
||||
|
||||
repositories {
|
||||
jcenter()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("org.apache.commons:commons-math3:3.6.1")
|
||||
implementation("org.apache.commons:commons-rng-simple:1.1")
|
||||
implementation("kscience.plotlykt:plotlykt-core:0.2.0")
|
||||
implementation("de.m3y.kformat:kformat:0.7")
|
||||
testImplementation("junit:junit:4.12")
|
||||
}
|
||||
|
||||
tasks.compileKotlin {
|
||||
kotlinOptions.jvmTarget = "1.8"
|
||||
}
|
||||
|
@ -1 +0,0 @@
|
||||
rootProject.name = 'trapping'
|
1
settings.gradle.kts
Normal file
1
settings.gradle.kts
Normal file
@ -0,0 +1 @@
|
||||
rootProject.name = "trapping"
|
@ -19,7 +19,7 @@ fun main() {
|
||||
SimulationManager().apply {
|
||||
comment = "Out of the box cross-sections"
|
||||
fileName = "trap[$e]"
|
||||
setFields(0.6, 3.7, 7.2)
|
||||
setFields(0.6, 3.6, 7.2)
|
||||
gasDensity = 1e19
|
||||
initialE = e
|
||||
range = 4000.0
|
@ -380,7 +380,7 @@ class Simulator(
|
||||
|
||||
|
||||
/**
|
||||
* Сложение вектора с учетом случайно распределения по фи
|
||||
* Vector addition, taking into account random phi distribution
|
||||
*
|
||||
* @param dTheta
|
||||
* @return resulting angle
|
||||
|
75
src/main/kotlin/ru/inr/mass/trapping/crosssections.kt
Normal file
75
src/main/kotlin/ru/inr/mass/trapping/crosssections.kt
Normal file
@ -0,0 +1,75 @@
|
||||
package ru.inr.mass.trapping
|
||||
|
||||
import de.m3y.kformat.Table
|
||||
import de.m3y.kformat.table
|
||||
import kscience.plotly.Plotly
|
||||
import kscience.plotly.layout
|
||||
import kscience.plotly.makeFile
|
||||
import kscience.plotly.models.AxisType
|
||||
import kscience.plotly.scatter
|
||||
|
||||
infix fun ClosedFloatingPointRange<Double>.step(step: Double): Sequence<Double> = sequence {
|
||||
var current = start
|
||||
|
||||
while (current <= endInclusive) {
|
||||
yield(current)
|
||||
current += step
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun main() {
|
||||
|
||||
val energies = ((1.0..20.0) step 0.2).toList() // energy in keV
|
||||
|
||||
val barn = 1e-22
|
||||
val sigmaEl = energies.map { Scatter.sigmael(it * 1000) / barn }
|
||||
val sigmaIon = energies.map { Scatter.sigmaion(it * 1000) / barn }
|
||||
val sigmaExc = energies.map { Scatter.sigmaexc(it * 1000) / barn }
|
||||
|
||||
Plotly.plot {
|
||||
scatter {
|
||||
x.numbers = energies
|
||||
y.numbers = sigmaEl
|
||||
name = "Elastic"
|
||||
}
|
||||
scatter {
|
||||
x.numbers = energies
|
||||
y.numbers = sigmaIon
|
||||
name = "Ionization"
|
||||
}
|
||||
scatter {
|
||||
x.numbers = energies
|
||||
y.numbers = sigmaExc
|
||||
name = "Excitation"
|
||||
}
|
||||
layout{
|
||||
yaxis {
|
||||
title = "Cross-section (Barn)"
|
||||
type = AxisType.log
|
||||
}
|
||||
xaxis{
|
||||
title = "Electron energy (KeV)"
|
||||
}
|
||||
|
||||
}
|
||||
}.makeFile()
|
||||
|
||||
val table = table {
|
||||
header("E(keV)", "elastic", "ion", "exc")
|
||||
|
||||
for (e in (12.0..18.6) step 0.1) {
|
||||
row(
|
||||
e,
|
||||
Scatter.sigmael(e * 1000) / barn,
|
||||
Scatter.sigmaion(e * 1000) / barn,
|
||||
Scatter.sigmaexc(e * 1000) / barn
|
||||
)
|
||||
}
|
||||
hints {
|
||||
borderStyle = Table.BorderStyle.SINGLE_LINE // or NONE
|
||||
}
|
||||
}.render(StringBuilder())
|
||||
|
||||
println(table)
|
||||
}
|
Loading…
Reference in New Issue
Block a user