Created
June 9, 2021 11:21
-
-
Save altavir/1b648446dfb2ce5a71c951fd4b51124b to your computer and use it in GitHub Desktop.
Visionforge and plotly.kt demonstration for quarks 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "cells": [ | |
| { | |
| "cell_type": "code", | |
| "execution_count": null, | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "@file:Repository(\"*mavenLocal\")\n", | |
| "@file:Repository(\"https://repo.kotlin.link\")\n", | |
| "@file:DependsOn(\"space.kscience:plotlykt-jupyter:0.4.3\")\n", | |
| "@file:DependsOn(\"space.kscience:visionforge-gdml-jupyter-jvm:0.2.0-dev-19\")" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": null, | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "import kotlin.random.Random\n", | |
| "import space.kscience.plotly.palettes.Xkcd\n", | |
| "\n", | |
| "Plotly.plot {\n", | |
| " histogram {\n", | |
| " x.numbers = List(500) { Random.nextDouble() }\n", | |
| " name = \"Random data\"\n", | |
| " histnorm = HistNorm.probability\n", | |
| " marker {\n", | |
| " color(Xkcd.BLUE_GREEN)\n", | |
| " }\n", | |
| " }\n", | |
| "\n", | |
| " layout {\n", | |
| " title = \"Normalized Histogram\"\n", | |
| " bargap = 0.1\n", | |
| " xaxis {\n", | |
| " tickfont {\n", | |
| " size = 16\n", | |
| " }\n", | |
| " }\n", | |
| " yaxis {\n", | |
| " tickfont {\n", | |
| " size = 16\n", | |
| " }\n", | |
| " }\n", | |
| " }\n", | |
| "}" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": null, | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "Gdml{\n", | |
| " val center = define.position(name = \"center\")\n", | |
| " structure {\n", | |
| " val air = materials.isotope(\"G4_AIR\")\n", | |
| " val tubeMaterial = materials.element(\"tubeium\")\n", | |
| " val boxMaterial = materials.element(\"boxium\")\n", | |
| "\n", | |
| " val segment = solids.tube(20, 5.0, \"segment\") {\n", | |
| " rmin = 17\n", | |
| " deltaphi = 60\n", | |
| " aunit = AUnit.DEG\n", | |
| " }\n", | |
| " val worldBox = solids.box(200, 200, 200, \"LargeBox\")\n", | |
| " val smallBox = solids.box(30, 30, 30, \"smallBox\")\n", | |
| " val segmentVolume = volume(tubeMaterial, segment, \"segment\")\n", | |
| " val composite = volume(boxMaterial, smallBox, \"composite\") {\n", | |
| " for (i in 0 until 6) {\n", | |
| " physVolume(segmentVolume, \"segment-$i\") {\n", | |
| " positionref = center\n", | |
| " rotation {\n", | |
| " z = 60 * i\n", | |
| " unit = AUnit.DEG\n", | |
| " }\n", | |
| " }\n", | |
| " }\n", | |
| " }\n", | |
| "\n", | |
| " world = volume(air, worldBox, \"world\") {\n", | |
| " for (i in 0 until 3) {\n", | |
| " for (j in 0 until 3) {\n", | |
| " for (k in 0 until 3) {\n", | |
| " physVolume(composite, \"composite-$i$j$k\") {\n", | |
| " position {\n", | |
| " x = (-50 + i * 50)\n", | |
| " y = (-50 + j * 50)\n", | |
| " z = (-50 + k * 50)\n", | |
| " }\n", | |
| " rotation {\n", | |
| " x = i * 120\n", | |
| " y = j * 120\n", | |
| " z = 120 * k\n", | |
| " }\n", | |
| " }\n", | |
| " }\n", | |
| " }\n", | |
| " }\n", | |
| " }\n", | |
| " }\n", | |
| "}" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": null, | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "GdmlShowCase.babyIaxo()" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": null, | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [] | |
| } | |
| ], | |
| "metadata": { | |
| "kernelspec": { | |
| "display_name": "Kotlin", | |
| "language": "kotlin", | |
| "name": "kotlin" | |
| }, | |
| "language_info": { | |
| "codemirror_mode": "text/x-kotlin", | |
| "file_extension": ".kt", | |
| "mimetype": "text/x-kotlin", | |
| "name": "kotlin", | |
| "nbconvert_exporter": "", | |
| "pygments_lexer": "kotlin", | |
| "version": "1.5.30-dev-598" | |
| } | |
| }, | |
| "nbformat": 4, | |
| "nbformat_minor": 4 | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment