Skip to content

Commit 65a7519

Browse files
committed
Add functions to save solution
postfix the phase name to species name when saving
1 parent bf7081e commit 65a7519

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/Simulation.jl

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,3 +764,28 @@ function rates(ssys::Q; ts::X=Array{Float64,1}()) where {Q<:SystemSimulation,X<:
764764
end
765765

766766
export rates
767+
768+
"""
769+
Save the simulation profile to a .csv file
770+
"""
771+
function save(sim::T, save_name::String) where {T<:Simulation}
772+
df = DataFrame(sim.sol)
773+
rename!(df, names(df)[sim.domain.indexes[1]:sim.domain.indexes[2]] .=> sim.names)
774+
for (thermovariable, index) in sim.domain.thermovariabledict
775+
rename!(df, names(df)[index] => thermovariable)
776+
end
777+
CSV.write(save_name, df)
778+
end
779+
780+
function save(syss::T, save_name::String) where {T<:SystemSimulation}
781+
df = DataFrame(syss.sol)
782+
for sim in syss.sims
783+
rename!(df, names(df)[sim.domain.indexes[1]:sim.domain.indexes[2]] .=> sim.names .* "($(sim.domain.phase.name))")
784+
for (thermovariable, index) in sim.domain.thermovariabledict
785+
rename!(df, names(df)[index] => thermovariable)
786+
end
787+
end
788+
CSV.write(save_name, df)
789+
end
790+
export save
791+

0 commit comments

Comments
 (0)