diff --git a/README.md b/README.md new file mode 100644 index 0000000..da02dc8 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +## Trapping simulation \ No newline at end of file diff --git a/build.gradle b/build.gradle deleted file mode 100644 index d64e25d..0000000 --- a/build.gradle +++ /dev/null @@ -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" -} - diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 0000000..7cf3972 --- /dev/null +++ b/build.gradle.kts @@ -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" +} + diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index 6e2d9b2..0000000 --- a/settings.gradle +++ /dev/null @@ -1 +0,0 @@ -rootProject.name = 'trapping' diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 0000000..4eaffda --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1 @@ +rootProject.name = "trapping" diff --git a/src/main/kotlin/ru/inr/mass/trapping/Trapping.kt b/src/main/kotlin/ru/inr/mass/trapping/Main.kt similarity index 96% rename from src/main/kotlin/ru/inr/mass/trapping/Trapping.kt rename to src/main/kotlin/ru/inr/mass/trapping/Main.kt index 327617a..85b592a 100644 --- a/src/main/kotlin/ru/inr/mass/trapping/Trapping.kt +++ b/src/main/kotlin/ru/inr/mass/trapping/Main.kt @@ -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 diff --git a/src/main/kotlin/ru/inr/mass/trapping/Simulator.kt b/src/main/kotlin/ru/inr/mass/trapping/Simulator.kt index 350242f..5f38f25 100644 --- a/src/main/kotlin/ru/inr/mass/trapping/Simulator.kt +++ b/src/main/kotlin/ru/inr/mass/trapping/Simulator.kt @@ -380,7 +380,7 @@ class Simulator( /** - * Сложение вектора с учетом случайно распределения по фи + * Vector addition, taking into account random phi distribution * * @param dTheta * @return resulting angle diff --git a/src/main/kotlin/ru/inr/mass/trapping/crosssections.kt b/src/main/kotlin/ru/inr/mass/trapping/crosssections.kt new file mode 100644 index 0000000..b14068b --- /dev/null +++ b/src/main/kotlin/ru/inr/mass/trapping/crosssections.kt @@ -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.step(step: Double): Sequence = 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) +} \ No newline at end of file