Skip to content

Commit

Permalink
Merge branch 'master' of github.com:ProjectTorreyPines/BalanceOfPlant…
Browse files Browse the repository at this point in the history
…Surogate
  • Loading branch information
TimSlendebroek committed Sep 24, 2024
2 parents 94baa24 + 1ee3d81 commit 6e2569a
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,26 @@ mutable struct BOPSurogate
end

function BOPSurogate(cycle_type::Symbol;data::String="BalanceOfPlantHypercubeN=16.csv")
df = DataFrames.DataFrame(CSV.File(joinpath(BalanceOfPlantSurogate.__BalanceOfPlantSurogate__,"data","BalanceOfPlantHypercubeN=16.csv")))
df = DataFrames.DataFrame(CSV.File(joinpath(BalanceOfPlantSurogate.__BalanceOfPlantSurogate__,"data",data)))
df = filter(row -> row.cycle_type == string(cycle_type), df)

sort!(df, [:total_power, :breeder_heat_load, :diverter_heatload,:wall_heat_load])
total_power = sort(unique(df.total_power))
breeder_heat_load = sort(unique(df.breeder_heat_load))
diverter_heatload = sort(unique(df.diverter_heatload))
sort!(df, [:diverter_heatload, :breeder_heat_load, :total_power])
total_power = unique(df.total_power)
breeder_heat_load = unique(df.breeder_heat_load)
diverter_heatload = unique(df.diverter_heatload)

thermal_efficiency_cycle = Array{Float64}(undef, size(total_power)..., size(breeder_heat_load)..., size(diverter_heatload)...)
thermal_efficiency_plant = Array{Float64}(undef, size(total_power)..., size(breeder_heat_load)..., size(diverter_heatload)...)
for (k, row) in enumerate(eachrow(df))
thermal_efficiency_cycle[k] = row.thermal_efficiency_cycle
thermal_efficiency_plant[k] = row.thermal_efficiency_plant
end

itp = extrapolate(interpolate((log10.(total_power), breeder_heat_load, diverter_heatload), thermal_efficiency_cycle, Gridded(Linear())), Flat())
itp = extrapolate(interpolate((log10.(total_power), breeder_heat_load, diverter_heatload), thermal_efficiency_plant, Gridded(Linear())), Flat())

return BOPSurogate(df, itp)
end

function predict_thermal_efficiency(BOP_sur::BOPSurogate,total_power::Float64,breeder_heat_load::Float64,diverter_heatload::Float64)
@assert 0 <= breeder_heat_load <=1
@assert 0 <= diverter_heatload <=1
return BOP_sur.thermal_efficiency(log10(total_power), breeder_heat_load,diverter_heatload)
end

0 comments on commit 6e2569a

Please sign in to comment.