Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Korean DEMO branch #411

Merged
merged 12 commits into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 99 additions & 0 deletions cases/KDEMO.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
"""
case_parameters(:KDEMO)

KDEMO

Arguments:
"""
function case_parameters(::Type{Val{:KDEMO}})::Tuple{ParametersAllInits,ParametersAllActors}
ini = ParametersInits()
act = ParametersActors()

ini.general.casename = "K-DEMO"
ini.general.init_from = :scalars

ini.build.layers = OrderedCollections.OrderedDict(
:gap_OH => 1.180137712438599,
:OH => 0.35554973675585266,
:gap_TF_OH => 0.068920461457739,
:hfs_TF => 0.3074802716013343,
:hfs_gap_low_temp_shield_TF => 0.06892046145773922,
:hfs_gap_vacuum_vessel_low_temp_shield => 0.06892046145773945,
:hfs_vacuum_vessel_wall_outer => 0.02,
:hfs_vacuum_vessel => 0.13230115364434794,
:hfs_vacuum_vessel_wall_inner => 0.02,
:hfs_gap_high_temp_shield_vacuum_vessel => 0.06892046145773945,
:hfs_high_temp_shield => 0.2067613843732179,
:hfs_blanket => 0.3316196291966129,
:hfs_first_wall => 0.02,
:plasma => 3.1014207655982666,
:lfs_first_wall => 0.02,
:lfs_blanket => 0.7654012311802618,
:lfs_high_temp_shield => 0.2067613843732179,
:lfs_gap_high_temp_shield_vacuum_vessel => 0.3446023072886959,
:lfs_vacuum_vessel_wall_inner => 0.02,
:lfs_vacuum_vessel => 0.13230115364434794,
:lfs_vacuum_vessel_wall_outer => 0.02,
:lfs_gap_vacuum_vessel_low_temp_shield => 0.068920461457739,
:lfs_gap_low_temp_shield_TF => 0.17230115364434795,
:lfs_TF => 0.3074802716013334,
:gap_cryostat => 1.4221989470234107,
:cryostat => 0.21209509270084714,
)
ini.build.plasma_gap = 0.125
ini.build.symmetric = false
ini.build.divertors = :lower
ini.build.n_first_wall_conformal_layers = 2

ini.material.wall = "Tungsten"
ini.material.blanket = "lithium-lead"
ini.material.shield = "Steel, Stainless 316"

ini.equilibrium.B0 = 7.5
ini.equilibrium.R0 = 6.8
ini.equilibrium.ϵ = 0.3088235294117647
ini.equilibrium.κ = 1.85
ini.equilibrium.δ = 0.485
ini.equilibrium.pressure_core = 964500.0
ini.equilibrium.ip = 1.2e7
ini.equilibrium.xpoints = :lower
ini.equilibrium.boundary_from = :scalars

ini.core_profiles.greenwald_fraction = 1.0
ini.core_profiles.greenwald_fraction_ped = 0.675
ini.core_profiles.T_ratio = 1.0
ini.core_profiles.T_shaping = 1.8
ini.core_profiles.n_shaping = 0.9
ini.core_profiles.zeff = 2.0
ini.core_profiles.rot_core = 0.0
ini.core_profiles.bulk = :DT
ini.core_profiles.impurity = :Ne
ini.core_profiles.helium_fraction = 0.01

ini.pf_active.n_coils_inside = 0
ini.pf_active.n_coils_outside = 6
ini.pf_active.technology = :LTS

ini.tf.n_coils = 18
ini.tf.technology = :LTS

ini.oh.n_coils = 6
ini.oh.technology = :LTS

ini.ec_launchers.power_launched = 5.0e7

ini.ic_antennas.power_launched = 5.0e7

ini.requirements.flattop_duration = 1800.0
ini.requirements.tritium_breeding_ratio = 1.1

act.ActorFluxMatcher.evolve_densities = Dict(
:He4 => :match_ne_scale, :He4_fast => :fixed,
:DT => :quasi_neutrality, :DT_fast => :fixed,
:electrons => :flux_match, :Ne20 => :match_ne_scale)

set_new_base!(ini)
set_new_base!(act)

return ini, act
end
3 changes: 3 additions & 0 deletions docs/src/cases_docs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ FUSE comes with a set of pre-cookes used cases.
The `case_parameters(:use_case, ...)` method returns the `ini` and `act` parameters for that specific `use_case`.
These `ini` and `act` can then be further customized before running a FUSE simulation.

To create your own case and add them to `FUSE/cases` copy one of the other cases as a template and change the ini/act parameters inside.
A handy way of generating the ini code from `your_ini` that you created in a notebook or elsewhere is to call the function `FUSE.case_parameter_creation_from_ini(your_ini)` which will return a nicely formatted code snippet.

!!! tip "Tip!"
Click on the `Source` button of each use case to see how each is setup

Expand Down
152 changes: 152 additions & 0 deletions examples/cases/K-DEMO.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "25928791-9f99-45b2-97c6-344cf86a68c0",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"using FUSE\n",
"using Plots;\n",
"FUSE.logging(Logging.Info; actors=Logging.Info);"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "eaaf74cc-61ce-4580-a7da-e878a9a4de57",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"ini, act = FUSE.case_parameters(:KDEMO)\n",
"display(ini.equilibrium)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "d4f1cb5b-c630-4151-8c9f-8b11af11755f",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"@show ini.oh.technology, ini.tf.technology, ini.pf_active.technology\n",
"# a note that this is ITER-like LTS"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "89e9650d-e208-4a96-abca-900d32141bea",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"dd_LTS = FUSE.init(ini, act);"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "5b7fb44e-7a56-4934-8f68-2f4d5379384e",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"dd = deepcopy(dd_LTS)\n",
"\n",
"act.ActorStabilityLimits.raise_on_breach = false\n",
"act.ActorHFSsizing.error_on_technology = false\n",
"\n",
"FUSE.ActorWholeFacility(dd, act);"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a44ab81b-92dd-4d91-a349-b6e09d1745d5",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"# Make magnets HTS (ideally we get K-DEMO LTS magnet techonolgy parameters)\n",
"ini.oh.technology = :HTS\n",
"ini.tf.technology = :HTS\n",
"ini.pf_active.technology = :HTS\n",
"\n",
"dd_HTS = FUSE.init(ini, act)\n",
"act.ActorPFcoilsOpt.do_plot = true\n",
"\n",
"act.ActorHFSsizing.verbose = true\n",
"\n",
"FUSE.ActorWholeFacility(dd_HTS, act);"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ced4ed81-60f3-4ca7-bc5b-52f6f28fdfd8",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"FUSE.digest(dd_HTS)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a9fca603-a505-41e0-9d08-2192e4c3d046",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"# Core transport according to turbulent and neoclassical fluxes with EPED H-mode at the edge\n",
"\n",
"act.ActorFluxMatcher.max_iterations = 300\n",
"act.ActorFluxMatcher.evolve_pedestal = true\n",
"act.ActorFluxMatcher.verbose = true\n",
"act.ActorTGLF.user_specified_model = \"sat1_em_iter\"\n",
"FUSE.ActorFluxMatcher(dd_HTS, act);"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "8b852868-aeb2-426e-8149-00b176e8829b",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"FUSE.digest(dd_HTS, \"K DEMO using FUSE WholeFacility\")"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Julia 1.9.3",
"language": "julia",
"name": "julia-1.9"
},
"language_info": {
"file_extension": ".jl",
"mimetype": "application/julia",
"name": "julia",
"version": "1.9.3"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
31 changes: 31 additions & 0 deletions src/parameters.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,34 @@ function case_parameters(case::Symbol; kw...)
end
return case_parameters(Val{case}; kw...)
end

"""
case_parameters_creation_from_ini(ini_case::AbstractParameters)

Useful function to create a case_paramter function for a case from an ini
"""
function case_parameters_creation_from_ini(ini_case::ParametersAllInits)
ini_base = ParametersInits()
for field in keys(ini_base)
code_string = ""
for sub_field in keys(getproperty(ini_base, field))
value_case = getproperty(getproperty(ini_case, field), sub_field, missing)
value_base = getproperty(getproperty(ini_base, field), sub_field, missing)
if value_case !== value_base
if typeof(value_case) <: Symbol
code_string = "ini.$field.$sub_field = :$value_case"
elseif typeof(value_case) <: String
code_string = "ini.$field.$sub_field = \"$value_case\""
elseif typeof(value_case) <: OrderedCollections.OrderedDict
code_string = "ini.$field.$sub_field = OrderedCollections.OrderedDict(\n " * join([":$k => $v," for (k, v) in value_case], "\n ") * "\n)"
else
code_string = "ini.$field.$sub_field = $value_case"
end
println(code_string)
end
end
if !isempty(code_string)
println()
end
end
end