Skip to content

Commit

Permalink
Merge branch 'master' of github.com:ProjectTorreyPines/FUSE.jl into c…
Browse files Browse the repository at this point in the history
…hease_cocos_test_added
  • Loading branch information
TimSlendebroek committed Aug 18, 2022
2 parents e413bcc + 658dd67 commit 059f12b
Show file tree
Hide file tree
Showing 49 changed files with 2,187 additions and 1,025 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/runtests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
using Pkg
Pkg.activate(".")
dependencies = PackageSpec[]
for package in ["IMAS", "IMASDD", "CoordinateConventions", "MillerExtendedHarmonic", "FusionMaterials", "VacuumFields", "Equilibrium", "TAUENN", "EPEDNN", "TGLFNN", "QED", "FiniteElementHermite", "CHEASE", "Fortran90Namelists", "EFIT"]
for package in ["IMAS", "IMASDD", "CoordinateConventions", "MillerExtendedHarmonic", "FusionMaterials", "VacuumFields", "Equilibrium", "TAUENN", "EPEDNN", "TGLFNN", "QED", "FiniteElementHermite", "Fortran90Namelists", "CHEASE", "EFIT", "NNeutronics"]
push!(dependencies, PackageSpec(url="https://project-torrey-pines:${{secrets.PTP_READ_TOKEN}}@github.com/ProjectTorreyPines/$package.jl.git"))
end
Pkg.add(dependencies)
Expand Down
17 changes: 10 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ install_no_registry:
julia -e '\
using Pkg;\
Pkg.activate(".");\
Pkg.develop(["IMAS", "IMASDD", "CoordinateConventions", "MillerExtendedHarmonic", "FusionMaterials", "VacuumFields", "Equilibrium", "TAUENN", "EPEDNN", "TGLFNN", "QED", "FiniteElementHermite", "Fortran90Namelists", "CHEASE", "EFIT"]);\
Pkg.develop(["IMAS", "IMASDD", "CoordinateConventions", "MillerExtendedHarmonic", "FusionMaterials", "VacuumFields", "Equilibrium", "TAUENN", "EPEDNN", "TGLFNN", "QED", "FiniteElementHermite", "Fortran90Namelists", "CHEASE", "EFIT", "NNeutronics"]);\
Pkg.activate();\
Pkg.develop(["FUSE", "IMAS", "IMASDD", "CoordinateConventions", "MillerExtendedHarmonic", "FusionMaterials", "VacuumFields", "Equilibrium", "TAUENN", "EPEDNN", "TGLFNN", "QED", "FiniteElementHermite", "Fortran90Namelists", "CHEASE", "EFIT"]);\
Pkg.develop(["FUSE", "IMAS", "IMASDD", "CoordinateConventions", "MillerExtendedHarmonic", "FusionMaterials", "VacuumFields", "Equilibrium", "TAUENN", "EPEDNN", "TGLFNN", "QED", "FiniteElementHermite", "Fortran90Namelists", "CHEASE", "EFIT", "NNeutronics"]);\
'

install: clone_update_all install_no_registry precompile
Expand Down Expand Up @@ -61,7 +61,7 @@ precompile:
julia -e 'using Pkg; Pkg.activate("."); Pkg.precompile()'

clone_update_all:
make -j 100 FUSE IMAS IMASDD CoordinateConventions MillerExtendedHarmonic FusionMaterials VacuumFields Equilibrium TAUENN EPEDNN TGLFNN QED FiniteElementHermite Fortran90Namelists CHEASE EFIT
make -j 100 FUSE IMAS IMASDD CoordinateConventions MillerExtendedHarmonic FusionMaterials VacuumFields Equilibrium TAUENN EPEDNN TGLFNN QED FiniteElementHermite Fortran90Namelists CHEASE EFIT NNeutronics

update: install clone_update_all precompile

Expand Down Expand Up @@ -101,16 +101,19 @@ EPEDNN:
QED:
$(call clone_update_repo,$@)

CHEASE:
FiniteElementHermite:
$(call clone_update_repo,$@)

EFIT:
Fortran90Namelists:
$(call clone_update_repo,$@)

Fortran90Namelists:
CHEASE:
$(call clone_update_repo,$@)

FiniteElementHermite:
EFIT:
$(call clone_update_repo,$@)

NNeutronics:
$(call clone_update_repo,$@)

docker_image:
Expand Down
2 changes: 2 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ FiniteElementHermite = "6ce10167-d368-4c0e-af34-9787cdd175e5"
Fortran90Namelists = "8fb689aa-71ff-4044-8071-0cffc910b57d"
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
FusionMaterials = "4c86da02-02c8-4634-8460-96566129f8e0"
GeoInterface = "cf35fbd7-0cd7-5166-be24-54bfbe79505f"
IMAS = "13ead8c1-b7d1-41bb-a6d0-5b8b65ed587a"
IMASDD = "06b86afa-9f21-11ec-2ef8-e51b8960cfc5"
Images = "916415d5-f1e6-5110-898d-aaa5f9f070e0"
Expand All @@ -33,6 +34,7 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
LoggingExtras = "e6f89c97-d47a-5376-807f-9c37f3926c36"
Metaheuristics = "bcdb8e00-2c21-11e9-3065-2b553b22f898"
MillerExtendedHarmonic = "c82744c2-dc08-461a-8c37-87ab04d0f9b8"
NNeutronics = "a9424c20-d414-11ec-167b-9106c24d956c"
NumericalIntegration = "e7bfaba1-d571-5449-8927-abc22e82249b"
Optim = "429524aa-4258-5aef-a3af-852621145aeb"
OrderedCollections = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
Expand Down
12 changes: 8 additions & 4 deletions cases/ARC.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
CFS/MIT ARC design
"""
function case_parameters(::Type{Val{:ARC}})::Tuple{ParametersAllInits, ParametersAllActors}
function case_parameters(::Type{Val{:ARC}})::Tuple{ParametersAllInits,ParametersAllActors}
ini = ParametersAllInits()
act = ParametersAllActors()
ini.general.casename = "ARC"
Expand All @@ -16,7 +16,7 @@ function case_parameters(::Type{Val{:ARC}})::Tuple{ParametersAllInits, Parameter
ini.equilibrium.B0 = -11.5
ini.equilibrium.Z0 = 0.0
ini.equilibrium.ip = 9.9e6
ini.equilibrium.βn = 1.4
ini.equilibrium.pressure_core = 1.45e6
ini.equilibrium.x_point = (3.1, 1.85)
ini.equilibrium.symmetric = true
act.ActorCXbuild.rebuild_wall = false
Expand Down Expand Up @@ -50,9 +50,12 @@ function case_parameters(::Type{Val{:ARC}})::Tuple{ParametersAllInits, Parameter
ini.tf.n_coils = 18
ini.tf.technology = coil_technology(:HTS)
ini.oh.technology = coil_technology(:HTS)
ini.oh.flattop_duration = 1800

ini.core_profiles.ne_ped = 7e19 #estimate (from ITER)
#ini.target.power_electric_net = 50E6 ?
ini.target.flattop_duration = 1800
#ini.target.tritium_breeding_ratio = 1.0 ?

ini.core_profiles.ne_ped = 1.0e20
ini.core_profiles.greenwald_fraction = 0.49
ini.core_profiles.helium_fraction = 0.10 #estimate
ini.core_profiles.T_shaping = 1.8 #estimate (from ITER)
Expand All @@ -65,6 +68,7 @@ function case_parameters(::Type{Val{:ARC}})::Tuple{ParametersAllInits, Parameter
ini.ic_antennas.power_launched = 4 * 1e6 #rf power coupled

act.ActorPFcoilsOpt.symmetric = true #note: symmetric, but not evenly spaced
# act.ActorEquilibrium.model = :CHEASE

return set_new_base!(ini), set_new_base!(act)
end
Expand Down
5 changes: 3 additions & 2 deletions cases/CAT.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
GA Compact Advanced Tokamak design
"""
function case_parameters(::Type{Val{:CAT}})::Tuple{ParametersAllInits, ParametersAllActors}
function case_parameters(::Type{Val{:CAT}})::Tuple{ParametersAllInits,ParametersAllActors}
ini = ParametersAllInits()
act = ParametersAllActors()

Expand All @@ -29,7 +29,6 @@ function case_parameters(::Type{Val{:CAT}})::Tuple{ParametersAllInits, Parameter
ini.tf.technology = coil_technology(:ITER, :TF)

ini.oh.technology = coil_technology(:ITER, :OH)
ini.oh.flattop_duration = 1000
ini.core_profiles.ne_ped = 7E19
ini.core_profiles.greenwald_fraction = 0.8
ini.core_profiles.helium_fraction = 0.01
Expand All @@ -40,6 +39,8 @@ function case_parameters(::Type{Val{:CAT}})::Tuple{ParametersAllInits, Parameter
ini.core_profiles.bulk = :DT
ini.core_profiles.impurity = :Ne

ini.target.flattop_duration = 1000

ini.nbi.power_launched = 20E6
ini.nbi.beam_energy = 200e3
ini.nbi.beam_mass = 2
Expand Down
5 changes: 3 additions & 2 deletions cases/D3D.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
DIII-D
"""
function case_parameters(::Type{Val{:D3D}})::Tuple{ParametersAllInits, ParametersAllActors}
function case_parameters(::Type{Val{:D3D}})::Tuple{ParametersAllInits,ParametersAllActors}
ini = ParametersAllInits()
act = ParametersAllActors()

Expand All @@ -27,7 +27,6 @@ function case_parameters(::Type{Val{:D3D}})::Tuple{ParametersAllInits, Parameter
ini.tf.technology = coil_technology(:copper)

ini.oh.technology = coil_technology(:copper)
ini.oh.flattop_duration = 5

ini.core_profiles.ne_ped = 5E19
ini.core_profiles.greenwald_fraction = 0.7
Expand All @@ -44,6 +43,8 @@ function case_parameters(::Type{Val{:D3D}})::Tuple{ParametersAllInits, Parameter
ini.nbi.beam_mass = 2
ini.nbi.toroidal_angle = 20.0 / 180 * pi

ini.target.flattop_duration = 5

act.ActorPFcoilsOpt.symmetric = true

return set_new_base!(ini), set_new_base!(act)
Expand Down
25 changes: 22 additions & 3 deletions cases/FPP.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ function case_parameters(::Type{Val{:FPP}}; version::Symbol, init_from::Symbol):
act.ActorHFSsizing.fixed_aspect_ratio = true
end

ini.target.tritium_breeding_ratio = 1.1
ini.target.cost = 5E9

ini.core_profiles.bulk = :DT
ini.core_profiles.rot_core = 0.0
ini.tf.shape = :princeton_D_scaled
Expand All @@ -42,7 +45,7 @@ function case_parameters(::Type{Val{:FPP}}; version::Symbol, init_from::Symbol):
if init_from == :ods
ini.pf_active.n_pf_coils_outside = 8
else
ini.pf_active.n_pf_coils_outside = 6
ini.pf_active.n_pf_coils_outside = 5
end

ini.material.shield = "Tungsten"
Expand All @@ -66,10 +69,26 @@ function case_parameters(::Type{Val{:FPP}}; version::Symbol, init_from::Symbol):
# greenwald_fraction is a powerful knob
ini.core_profiles.greenwald_fraction = 0.9

# ini.equilibrium.δ *= -1 # negative triangularity
# negative triangularity
# ini.equilibrium.δ *= -1

# ini.equilibrium.ζ = 0.1 # squareness
# squareness
# ini.equilibrium.ζ = 0.1
# act.ActorEquilibrium.model = :CHEASE

# add wall layer
if true
gasc_add_wall_layers!(ini.build.layers; thickness=0.02)
if version != :v1
ini.build.n_first_wall_conformal_layers = 2
end
end

# bucking
ini.center_stack.bucked = false
if ini.center_stack.bucked
gasc_buck_OH_TF!(ini.build.layers)
end

return ini, act
end
17 changes: 8 additions & 9 deletions cases/HDB5.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import CSV
For description of cases/variables see https://osf.io/593q6/
"""
function case_parameters(::Type{Val{:HDB5}}; tokamak::Union{String,Symbol}=:any, case=missing, database_case=missing)::Tuple{ParametersAllInits, ParametersAllActors}
function case_parameters(::Type{Val{:HDB5}}; tokamak::Union{String,Symbol}=:any, case=missing, database_case=missing)::Tuple{ParametersAllInits,ParametersAllActors}
if !ismissing(database_case)
data_row = load_hdb5(database_case=database_case)
elseif !ismissing(case)
Expand All @@ -30,9 +30,8 @@ function case_parameters(data_row::DataFrames.DataFrameRow)
ini.equilibrium.ϵ = data_row[:AMIN] / data_row[:RGEO]
ini.equilibrium.κ = data_row[:KAPPA]
ini.equilibrium.δ = data_row[:DELTA]
ini.equilibrium.βn = 1.0
ini.equilibrium.ip = data_row[:IP]

ini.equilibrium.pressure_core = IMAS.pressure_avg_from_beta_n(1.0, data_row[:AMIN], data_row[:BT], data_row[:IP]) * 3.0
act.ActorSolovev.area = data_row[:AREA]
act.ActorSolovev.volume = data_row[:VOL]

Expand Down Expand Up @@ -62,8 +61,8 @@ function case_parameters(data_row::DataFrames.DataFrameRow)

# Core_profiles parameters
ini.core_profiles.ne_ped = data_row[:NEL] / 1.3
ini.core_profiles.greenwald_fraction = data_row[:NEL]*1e-20 / (data_row[:IP]/1e6 / (pi * data_row[:AMIN]^2 ))
ini.core_profiles.helium_fraction = 0.
ini.core_profiles.greenwald_fraction = data_row[:NEL] * 1e-20 / (data_row[:IP] / 1e6 / (pi * data_row[:AMIN]^2))
ini.core_profiles.helium_fraction = 0.0
ini.core_profiles.T_shaping = 1.8
ini.core_profiles.w_ped = 0.03
ini.core_profiles.zeff = data_row[:ZEFF]
Expand Down Expand Up @@ -98,10 +97,10 @@ end
function load_hdb5(tokamak::Union{String,Symbol}=:all; maximum_ohmic_fraction::Float64=0.25, database_case::Union{Int,Missing}=missing, extra_signal_names=Union{String,Symbol}[])
# For description of variables see https://osf.io/593q6/
run_df = CSV.read(joinpath(@__DIR__, "..", "sample", "HDB5_compressed.csv"), DataFrames.DataFrame)
run_df[:,"database_case"] = collect(1:length(run_df[:,"TOK"]))
run_df[:, "database_case"] = collect(1:length(run_df[:, "TOK"]))

if !ismissing(database_case)
return run_df[run_df.database_case .== database_case, :]
return run_df[run_df.database_case.==database_case, :]
end

signal_names = ["TOK", "SHOT", "AMIN", "KAPPA", "DELTA", "NEL", "ZEFF", "TAUTH", "RGEO", "BT", "IP", "PNBI", "ENBI", "PICRH", "PECRH", "POHM", "MEFF", "VOL", "AREA", "WTH", "CONFIG"]
Expand All @@ -113,8 +112,8 @@ function load_hdb5(tokamak::Union{String,Symbol}=:all; maximum_ohmic_fraction::F
# some basic filters
run_df = run_df[(run_df.TOK.!="T10").&(run_df.TOK.!="TDEV").&(run_df.KAPPA.>1.0).&(run_df.DELTA.<0.79).&(1.6 .< run_df.MEFF .< 2.2).&(1.1 .< run_df.ZEFF .< 5.9), :]
# Filter cases where the ohmic power is dominating
run_df[:,"Paux"] = run_df[:,"PNBI"] .+ run_df[:,"PECRH"] .+ run_df[:,"PICRH"] .+ run_df[:,"POHM"]
run_df = run_df[run_df[:,"POHM"] .< maximum_ohmic_fraction .* (run_df[:,"Paux"] .- run_df[:,"POHM"]),:]
run_df[:, "Paux"] = run_df[:, "PNBI"] .+ run_df[:, "PECRH"] .+ run_df[:, "PICRH"] .+ run_df[:, "POHM"]
run_df = run_df[run_df[:, "POHM"].<maximum_ohmic_fraction.*(run_df[:, "Paux"].-run_df[:, "POHM"]), :]
if !(Symbol(tokamak) in [:all, :any])
run_df = run_df[run_df.TOK.==String(tokamak), :]
end
Expand Down
11 changes: 7 additions & 4 deletions cases/ITER.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,18 @@ function case_parameters(::Type{Val{:ITER}}; init_from::Symbol)::Tuple{Parameter
ini.equilibrium.B0 = -5.3
ini.equilibrium.Z0 = 0.4
ini.equilibrium.ip = 15e6
ini.equilibrium.βn = 2.0
ini.equilibrium.pressure_core = 0.643e6
ini.equilibrium.x_point = true
ini.equilibrium.symmetric = false
ini.equilibrium.MXH_params = [
6.19245, 0.39528, 0.32331, 1.82302, 0.00337,
0.15912, -0.05842, -0.04573, 0.00694, 0.00614,
0.00183, 0.43714, 0.09583, -0.05597, -0.01655,
0.00204, 0.00306]
ini.equilibrium.boundary_from = :MXH_params
act.ActorCXbuild.rebuild_wall = true
act.ActorHFSsizing.fixed_aspect_ratio = true
# act.ActorEquilibrium.model = :CHEASE
end

# explicitly set thickness of radial build layers
Expand All @@ -48,9 +50,9 @@ function case_parameters(::Type{Val{:ITER}}; init_from::Symbol)::Tuple{Parameter
layers[:hfs_TF] = 1.10
layers[:hfs_vacuum_vessel] = 0.30
layers[:hfs_shield] = 0.40
layers[:hfs_wall] = 0.06
layers[:hfs_wall] = 0.1
layers[:plasma] = 4.40
layers[:lfs_wall] = 0.17
layers[:lfs_wall] = 0.1
layers[:lfs_shield] = 0.40
layers[:lfs_vacuum_vessel] = 1.05
layers[:lfs_TF] = 1.10
Expand All @@ -69,9 +71,10 @@ function case_parameters(::Type{Val{:ITER}}; init_from::Symbol)::Tuple{Parameter
ini.tf.technology = coil_technology(:ITER, :TF)

ini.oh.technology = coil_technology(:ITER, :OH)
ini.oh.flattop_duration = 1000
act.ActorFluxSwing.operate_at_j_crit = false

ini.target.flattop_duration = 1800

ini.core_profiles.ne_ped = 7e19
ini.core_profiles.greenwald_fraction = 0.9
ini.core_profiles.helium_fraction = 0.01
Expand Down
13 changes: 6 additions & 7 deletions cases/SPARC.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
CFS/MIT SPARC design
"""
function case_parameters(::Type{Val{:SPARC}})::Tuple{ParametersAllInits, ParametersAllActors}
function case_parameters(::Type{Val{:SPARC}})::Tuple{ParametersAllInits,ParametersAllActors}
ini = ParametersAllInits()
act = ParametersAllActors()
ini.general.casename = "SPARC"
Expand All @@ -16,7 +16,7 @@ function case_parameters(::Type{Val{:SPARC}})::Tuple{ParametersAllInits, Paramet
ini.equilibrium.B0 = -12.2
ini.equilibrium.Z0 = 0.0
ini.equilibrium.ip = 8.7e6
ini.equilibrium.βn = 9.05 # high beta only for purpose of getting reasonable boundary with Solovev (otherwise should be 1)
ini.equilibrium.pressure_core = 2.22e6
ini.equilibrium.x_point = (1.55, 1.1)
ini.equilibrium.symmetric = true
act.ActorCXbuild.rebuild_wall = false
Expand Down Expand Up @@ -46,9 +46,10 @@ function case_parameters(::Type{Val{:SPARC}})::Tuple{ParametersAllInits, Paramet
ini.tf.n_coils = 18 #estimate (from ARC)
ini.tf.technology = coil_technology(:HTS)
ini.oh.technology = coil_technology(:HTS)
ini.oh.flattop_duration = 10

ini.core_profiles.ne_ped = 1.9e20
ini.target.flattop_duration = 10

ini.core_profiles.ne_ped = 1.5e20
ini.core_profiles.greenwald_fraction = 0.37
ini.core_profiles.helium_fraction = 0.1 #estimate
ini.core_profiles.T_shaping = 1.8 #estimate (from ITER)
Expand All @@ -58,12 +59,10 @@ function case_parameters(::Type{Val{:SPARC}})::Tuple{ParametersAllInits, Paramet
ini.core_profiles.bulk = :DT
ini.core_profiles.impurity = :Ne #estimate (from ITER)

ini.nbi.power_launched = 0.0
ini.nbi.beam_energy = 0.0
ini.ec_launchers.power_launched = 0.0
ini.ic_antennas.power_launched = 11.1 * 1e6 #25 MW maximum available, P_threshold = 21 MW

act.ActorPFcoilsOpt.symmetric = true
# act.ActorEquilibrium.model = :CHEASE

return set_new_base!(ini), set_new_base!(act)
end
Expand Down
1 change: 1 addition & 0 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import IMAS
import IMASDD
import AbstractTrees
import ProgressMeter
using InteractiveUtils: subtypes

function html_link_repr(par::FUSE.AbstractParameter)
return "©" * join(FUSE.path(par), ".") * "©©" * string(par._name) * "©"
Expand Down
Loading

0 comments on commit 059f12b

Please sign in to comment.