Skip to content

Instantly share code, notes, and snippets.

@altavir
Created June 29, 2021 13:39
Show Gist options
  • Save altavir/dd3490148f4962d473a1b9f8bdc2f366 to your computer and use it in GitHub Desktop.
Save altavir/dd3490148f4962d473a1b9f8bdc2f366 to your computer and use it in GitHub Desktop.
Casus sccience seminar materials
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"@file:Repository(\"https://repo.kotlin.link\")\n",
"@file:DependsOn(\"space.kscience:visionforge-gdml-jupyter-jvm:0.2.0-dev-20\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"val cubes = 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": {
"tags": []
},
"outputs": [],
"source": [
"cubes"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"cubes.encodeToString()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import java.io.File\n",
"import kotlin.io.*\n",
"\n",
"File(\"cubesExport.gdml\").writeText(cubes.encodeToString())"
]
},
{
"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
}
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@altavir
Copy link
Author

altavir commented Jun 29, 2021

The cell content was cleared to limit notebook size.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment