From 2baedd7b9fbc75e2952e05a7bf062b1056f9ebd5 Mon Sep 17 00:00:00 2001 From: kanamaru-masanori Date: Wed, 22 Nov 2023 05:27:11 +0900 Subject: [PATCH 01/15] Update TPM.jl Change the arguments of the struct to store the TPM result from `time_begin` and `time_end ` to `times_to_save`. --- src/TPM.jl | 120 +++++++++++++++++++++++++---------------------------- 1 file changed, 56 insertions(+), 64 deletions(-) diff --git a/src/TPM.jl b/src/TPM.jl index 8187b526..5f712d6b 100644 --- a/src/TPM.jl +++ b/src/TPM.jl @@ -235,26 +235,24 @@ Output data format for `SingleTPM` - `torque` : Thermal torque on the asteroid [N ⋅ m] ## Saved only at the time steps desired by the user -- `time_begin` : Time to start storing temperature -- `time_end` : Time to finish storing temperature -- `surf_temp` : Surface temperature, a matrix in size of `(Ns, Nt)`. +- `times_to_save` : Timesteps to save temperature +- `surf_temp` : Surface temperature, a matrix in size of `(Ns, Nt)`. - `Ns` : Number of faces - `Nt` : Number of time steps to save surface temperature -- `face_temp` : Temperature as a function of depth and time, `Dict` with face ID as key and a matrix `(Nz, Nt)` as an entry. +- `face_temp` : Temperature as a function of depth and time, `Dict` with face ID as key and a matrix `(Nz, Nt)` as an entry. - `Nz` : The number of the depth nodes - `Nt` : The number of time steps to save temperature """ struct SingleTPMResult - E_in ::Vector{Float64} - E_out ::Vector{Float64} - E_cons ::Vector{Union{Float64, Missing}} - force ::Vector{SVector{3, Float64}} - torque ::Vector{SVector{3, Float64}} - - time_begin ::Float64 - time_end ::Float64 - surf_temp ::Matrix{Float64} - face_temp ::Dict{Int, Matrix{Float64}} + E_in ::Vector{Float64} + E_out ::Vector{Float64} + E_cons ::Vector{Union{Float64, Missing}} + force ::Vector{SVector{3, Float64}} + torque ::Vector{SVector{3, Float64}} + + times_to_save ::Vector{Float64} + surf_temp ::Matrix{Float64} + face_temp ::Dict{Int, Matrix{Float64}} end @@ -262,27 +260,24 @@ end Outer constructor of `SingleTPMResult` # Arguments -- `stpm` : Thermophysical model for a single asteroid -- `ephem` : Ephemerides -- `time_begin` : Time to start storing temperature -- `time_end` : Time to finish storing temperature -- `face_ID` : Indices of faces at which you want to save temperature distribution in depth direction +- `stpm` : Thermophysical model for a single asteroid +- `ephem` : Ephemerides +- `times_to_save` : Timesteps to save temperature +- `face_ID` : Face indices where to save subsurface temperature """ -function SingleTPMResult(stpm::SingleTPM, ephem, time_begin::Real, time_end::Real, face_ID::Vector{Int}) +function SingleTPMResult(stpm::SingleTPM, ephem, times_to_save::Vector{Float64}, face_ID::Vector{Int}) E_in = zeros(length(ephem.time)) E_out = zeros(length(ephem.time)) E_cons = Vector{Union{Float64, Missing}}(missing, length(ephem.time)) force = zeros(SVector{3, Float64}, length(ephem.time)) torque = zeros(SVector{3, Float64}, length(ephem.time)) - Nt_save = count(@. time_begin ≤ ephem.time < time_end) # Number of time steps to save temperature - - surf_temp = zeros(length(stpm.shape.faces), Nt_save) + surf_temp = zeros(length(stpm.shape.faces), length(times_to_save)) face_temp = Dict{Int, Matrix{Float64}}( - nₛ => zeros(stpm.thermo_params.Nz, Nt_save) for nₛ in face_ID + nₛ => zeros(stpm.thermo_params.Nz, length(times_to_save)) for nₛ in face_ID ) - return SingleTPMResult(E_in, E_out, E_cons, force, torque, time_begin, time_end, surf_temp, face_temp) + return SingleTPMResult(E_in, E_out, E_cons, force, torque, times_to_save, surf_temp, face_temp) end @@ -305,16 +300,15 @@ end Outer constructor of `BinaryTPMResult` # Arguments -- `btpm` : Thermophysical model for a binary asteroid -- `ephem` : Ephemerides -- `time_begin` : Time to start storing temperature (Common to both the primary and the secondary) -- `time_end` : Time to finish storing temperature (Common to both the primary and the secondary) -- `face_ID_pri` : Face indices at which you want to save temperature as a function of depth for the primary -- `face_ID_sec` : Face indices at which you want to save temperature as a function of depth for the secondary +- `btpm` : Thermophysical model for a binary asteroid +- `ephem` : Ephemerides +- `times_to_save` : Timesteps to save temperature (Common to both the primary and the secondary) +- `face_ID_pri` : Face indices at which you want to save temperature as a function of depth for the primary +- `face_ID_sec` : Face indices at which you want to save temperature as a function of depth for the secondary """ -function BinaryTPMResult(btpm::BinaryTPM, ephem, time_begin::Real, time_end::Real, face_ID_pri::Vector{Int}, face_ID_sec::Vector{Int}) - result_pri = SingleTPMResult(btpm.pri, ephem, time_begin, time_end, face_ID_pri) - result_sec = SingleTPMResult(btpm.sec, ephem, time_begin, time_end, face_ID_sec) +function BinaryTPMResult(btpm::BinaryTPM, ephem, times_to_save::Vector{Float64}, face_ID_pri::Vector{Int}, face_ID_sec::Vector{Int}) + result_pri = SingleTPMResult(btpm.pri, ephem, times_to_save, face_ID_pri) + result_sec = SingleTPMResult(btpm.sec, ephem, times_to_save, face_ID_sec) return BinaryTPMResult(result_pri, result_sec) end @@ -331,7 +325,7 @@ Save the results of TPM at the time step `nₜ` to `result`. - `ephem` : Ephemerides - `nₜ` : Time step to save data """ -function update_TPM_result!(result::SingleTPMResult, stpm::SingleTPM, ephem, nₜ::Integer) +function update_TPM_result!(result::SingleTPMResult, stpm::SingleTPM, ephem, nₜ::Integer, times_to_save::Vector{Float64}) result.E_in[nₜ] = energy_in(stpm) result.E_out[nₜ] = energy_out(stpm) result.force[nₜ] = stpm.force @@ -350,9 +344,8 @@ function update_TPM_result!(result::SingleTPMResult, stpm::SingleTPM, ephem, n result.E_cons[nₜ] = ΣE_out / ΣE_in end - if result.time_begin ≤ ephem.time[nₜ] < result.time_end # if you want to save temperature at this time step - nₜ_offset = count(@. ephem.time < result.time_begin) # Index-offset before storing temperature - nₜ_save = nₜ - nₜ_offset + if t in times_to_save # In the step of saving temperature + nₜ_save = findfirst(isequal(t), times_to_save) result.surf_temp[:, nₜ_save] .= surface_temperature(stpm) @@ -374,9 +367,9 @@ Save the results of TPM at the time step `nₜ` to `result`. - `ephem` : Ephemerides - `nₜ` : Time step """ -function update_TPM_result!(result::BinaryTPMResult, btpm::BinaryTPM, ephem, nₜ::Integer) - update_TPM_result!(result.pri, btpm.pri, ephem, nₜ) - update_TPM_result!(result.sec, btpm.sec, ephem, nₜ) +function update_TPM_result!(result::BinaryTPMResult, btpm::BinaryTPM, ephem, nₜ::Integer, times_to_save::Vector{Float64}) + update_TPM_result!(result.pri, btpm.pri, ephem, nₜ, times_to_save) + update_TPM_result!(result.sec, btpm.sec, ephem, nₜ, times_to_save) end @@ -395,7 +388,7 @@ Export the result of `SingleTPM` to CSV files. - Save the depths of the calculation nodes - Save README for the data file """ -function export_TPM_results(dirpath, result::SingleTPMResult, stpm::SingleTPM, ephem) +function export_TPM_results(dirpath, result::SingleTPMResult, stpm::SingleTPM, ephem, times_to_save::Vector{Float64}) df = DataFrame() df.time = ephem.time @@ -411,13 +404,14 @@ function export_TPM_results(dirpath, result::SingleTPMResult, stpm::SingleTPM, e CSV.write(joinpath(dirpath, "data.csv"), df) - header = string.(ephem.time[@. result.time_begin ≤ ephem.time < result.time_end]) # Time to save temperature in String - + ##= Surface temperature =## + header = string.(times_to_save) CSV.write( joinpath(dirpath, "surf_temp.csv"), DataFrame(result.surf_temp, header) ) + ##= Subsurface temperature =## for (nₛ, temp) in result.face_temp CSV.write( joinpath(dirpath, "face_temp_$(lpad(nₛ, 7, '0')).csv"), @@ -438,15 +432,15 @@ Export the result of `BinaryTPM` to CSV files. - `btpm` : Thermophysical model for a binary asteroid - `ephem` : Ephemerides """ -function export_TPM_results(dirpath, result::BinaryTPMResult, btpm::BinaryTPM, ephem) +function export_TPM_results(dirpath, result::BinaryTPMResult, btpm::BinaryTPM, ephem, times_to_save::Vector{Float64}) dirpath_pri = joinpath(dirpath, "pri") dirpath_sec = joinpath(dirpath, "sec") mkpath(dirpath_pri) mkpath(dirpath_sec) - export_TPM_results(dirpath_pri, result.pri, btpm.pri, ephem) - export_TPM_results(dirpath_sec, result.sec, btpm.sec, ephem) + export_TPM_results(dirpath_pri, result.pri, btpm.pri, ephem, times_to_save) + export_TPM_results(dirpath_sec, result.sec, btpm.sec, ephem, times_to_save) end @@ -554,20 +548,19 @@ end Run TPM for a single asteroid. # Arguments -- `stpm` : Thermophysical model for a single asteroid -- `ephem` : Ephemerides +- `stpm` : Thermophysical model for a single asteroid +- `ephem` : Ephemerides - `ephem.time` : Ephemeris times - `ephem.sun` : Sun's position in the asteroid-fixed frame (Not normalized) -- `time_begin` : Time to start saving temperature -- `time_end` : Time to finish saving temperature -- `face_ID` : Face indices where to save subsurface termperature +- `times_to_save` : Timesteps to save temperature +- `face_ID` : Face indices where to save subsurface termperature # Keyword arguments - `show_progress` : Flag to show the progress meter """ -function run_TPM!(stpm::SingleTPM, ephem, time_begin::Real, time_end::Real, face_ID::Vector{Int}; show_progress=true) +function run_TPM!(stpm::SingleTPM, ephem, times_to_save::Vector{Float64}, face_ID::Vector{Int}; show_progress=true) - result = SingleTPMResult(stpm, ephem, time_begin, time_end, face_ID) + result = SingleTPMResult(stpm, ephem, times_to_save, face_ID) ## ProgressMeter setting if show_progress @@ -584,7 +577,7 @@ function run_TPM!(stpm::SingleTPM, ephem, time_begin::Real, time_end::Real, face update_thermal_force!(stpm) - update_TPM_result!(result, stpm, ephem, nₜ) # Save data + update_TPM_result!(result, stpm, ephem, nₜ, times_to_save) # Save data ## Update the progress meter if show_progress @@ -609,25 +602,24 @@ end Run TPM for a binary asteroid. # Arguments -- `btpm` : Thermophysical model for a binary asteroid -- `ephem` : Ephemerides +- `btpm` : Thermophysical model for a binary asteroid +- `ephem` : Ephemerides - `time` : Ephemeris times - `sun1` : Sun's position in the primary's frame - `sun2` : Sun's position in the secondary's frame - `sec` : Secondary's position in the primary's frame - `P2S` : Rotation matrix from primary to secondary frames - `S2P` : Rotation matrix from secondary to primary frames -- `time_begin` : Time to start saving temperature -- `time_end` : Time to finish saving temperature -- `face_ID_pri` : Face indices where to save subsurface termperature for the primary -- `face_ID_sec` : Face indices where to save subsurface termperature for the secondary +- `times_to_save` : Timesteps to save temperature +- `face_ID_pri` : Face indices where to save subsurface termperature for the primary +- `face_ID_sec` : Face indices where to save subsurface termperature for the secondary # Keyword arguments - `show_progress` : Flag to show the progress meter """ -function run_TPM!(btpm::BinaryTPM, ephem, time_begin::Real, time_end::Real, face_ID_pri::Vector{Int}, face_ID_sec::Vector{Int}; show_progress=true) +function run_TPM!(btpm::BinaryTPM, ephem, times_to_save::Vector{Float64}, face_ID_pri::Vector{Int}, face_ID_sec::Vector{Int}; show_progress=true) - result = BinaryTPMResult(btpm, ephem, time_begin, time_end, face_ID_pri, face_ID_sec) + result = BinaryTPMResult(btpm, ephem, times_to_save, face_ID_pri, face_ID_sec) ## ProgressMeter setting if show_progress @@ -650,7 +642,7 @@ function run_TPM!(btpm::BinaryTPM, ephem, time_begin::Real, time_end::Real, face update_thermal_force!(btpm) - update_TPM_result!(result, btpm, ephem, nₜ) # Save data + update_TPM_result!(result, btpm, ephem, nₜ, times_to_save) # Save data ## Update the progress meter if show_progress From fcd6a2011726a334f99d076cbbd8b74da8e9f02c Mon Sep 17 00:00:00 2001 From: kanamaru-masanori Date: Wed, 22 Nov 2023 05:27:25 +0900 Subject: [PATCH 02/15] Update test scripts --- test/TPM_Didymos.jl | 15 ++++++++------- test/TPM_Ryugu.jl | 19 ++++++++++--------- test/non-uniform_thermoparams.jl | 19 ++++++++++--------- 3 files changed, 28 insertions(+), 25 deletions(-) diff --git a/test/TPM_Didymos.jl b/test/TPM_Didymos.jl index 1e55ff7f..731ee16d 100644 --- a/test/TPM_Didymos.jl +++ b/test/TPM_Didymos.jl @@ -51,7 +51,9 @@ et_begin = SPICE.utc2et("2027-02-18T00:00:00") # Start time of TPM et_end = et_begin + 2P₂ # End time of TPM - step = P₂ / 72 # Time step of TPM + + nsteps_in_rotation = 72 # Number of steps in one rotation period + step = P₂ / nsteps_in_rotation # Time step of TPM et_range = et_begin : step : et_end """ @@ -137,15 +139,14 @@ AsteroidThermoPhysicalModels.init_temperature!(btpm, 200.) ##= Run TPM =## - time_begin = ephem.time[end] - P₂ # Time to start storing temperature - time_end = ephem.time[end] # Time to end storing temperature - face_ID_pri = [1, 2, 3, 4, 10] # Face indices at which you want to save underground temperature for the primary - face_ID_sec = [1, 2, 3, 4, 20] # Face indices at which you want to save underground temperature for the secondary + times_to_save = ephem.time[end-nsteps_in_rotation:end] # Save temperature during the final rotation + face_ID_pri = [1, 2, 3, 4, 10] # Face indices to save subsurface temperature of the primary + face_ID_sec = [1, 2, 3, 4, 20] # Face indices to save subsurface temperature of the secondary - result = AsteroidThermoPhysicalModels.run_TPM!(btpm, ephem, time_begin, time_end, face_ID_pri, face_ID_sec) + result = AsteroidThermoPhysicalModels.run_TPM!(btpm, ephem, times_to_save, face_ID_pri, face_ID_sec) ##= Save TPM result =## savedir = "TPM_Didymos" mkpath(savedir) - AsteroidThermoPhysicalModels.export_TPM_results(savedir, result, btpm, ephem) + AsteroidThermoPhysicalModels.export_TPM_results(savedir, result, btpm, ephem, times_to_save) end diff --git a/test/TPM_Ryugu.jl b/test/TPM_Ryugu.jl index d1a5f4c1..b63f9e87 100644 --- a/test/TPM_Ryugu.jl +++ b/test/TPM_Ryugu.jl @@ -39,10 +39,12 @@ end ##= Ephemerides =## - P = SPICE.convrt(7.63262, "hours", "seconds") # Rotation period of Ryugu - et_begin = SPICE.utc2et("2018-07-01T00:00:00") # Start time of TPM - et_end = et_begin + 2P # End time of TPM - step = P / 360 # Time step of TPM, corresponding to 1 deg rotation + P = SPICE.convrt(7.63262, "hours", "seconds") # Rotation period of Ryugu + et_begin = SPICE.utc2et("2018-07-01T00:00:00") # Start time of TPM + et_end = et_begin + 2P # End time of TPM + + nsteps_in_rotation = 72 # Number of steps in one rotation period + step = P / nsteps_in_rotation # Time step of TPM et_range = et_begin : step : et_end """ @@ -94,14 +96,13 @@ AsteroidThermoPhysicalModels.init_temperature!(stpm, 200) ##= Run TPM =## - time_begin = ephem.time[end] - P # Time to start storing temperature - time_end = ephem.time[end] # Time to end storing temperature - face_ID = [1, 2, 3, 4, 10] # Face indices at which you want to save underground temperature + times_to_save = ephem.time[end-nsteps_in_rotation:end] # Save temperature during the final rotation + face_ID = [1, 2, 3, 4, 10] # Face indices to save subsurface temperature - result = AsteroidThermoPhysicalModels.run_TPM!(stpm, ephem, time_begin, time_end, face_ID) + result = AsteroidThermoPhysicalModels.run_TPM!(stpm, ephem, times_to_save, face_ID) ##= Save TPM result =## savedir = "TPM_Ryugu" mkpath(savedir) - AsteroidThermoPhysicalModels.export_TPM_results(savedir, result, stpm, ephem) + AsteroidThermoPhysicalModels.export_TPM_results(savedir, result, stpm, ephem, times_to_save) end diff --git a/test/non-uniform_thermoparams.jl b/test/non-uniform_thermoparams.jl index b8ab96d5..d5694324 100644 --- a/test/non-uniform_thermoparams.jl +++ b/test/non-uniform_thermoparams.jl @@ -41,10 +41,12 @@ end ##= Ephemerides =## - P = SPICE.convrt(7.63262, "hours", "seconds") # Rotation period of Ryugu - et_begin = SPICE.utc2et("2018-07-01T00:00:00") # Start time of TPM - et_end = et_begin + 2P # End time of TPM - step = P / 360 # Time step of TPM, corresponding to 1 deg rotation + P = SPICE.convrt(7.63262, "hours", "seconds") # Rotation period of Ryugu + et_begin = SPICE.utc2et("2018-07-01T00:00:00") # Start time of TPM + et_end = et_begin + 2P # End time of TPM + + nsteps_in_rotation = 120 # Number of steps in one rotation period + step = P / nsteps_in_rotation # Time step of TPM et_range = et_begin : step : et_end """ @@ -107,14 +109,13 @@ AsteroidThermoPhysicalModels.init_temperature!(stpm, 200) ##= Run TPM =## - time_begin = ephem.time[end] - P # Time to start storing temperature - time_end = ephem.time[end] # Time to end storing temperature - face_ID = [1, 2, 3, 4, 10] # Face indices at which you want to save underground temperature + times_to_save = ephem.time[end-nsteps_in_rotation:end] # Save temperature during the final rotation + face_ID = [1, 2, 3, 4, 10] # Face indices to save subsurface temperature - result = AsteroidThermoPhysicalModels.run_TPM!(stpm, ephem, time_begin, time_end, face_ID) + result = AsteroidThermoPhysicalModels.run_TPM!(stpm, ephem, times_to_save, face_ID) ##= Save TPM result =##' savedir = "non-uniform_thermoparams" mkpath(savedir) - AsteroidThermoPhysicalModels.export_TPM_results(savedir, result, stpm, ephem) + AsteroidThermoPhysicalModels.export_TPM_results(savedir, result, stpm, ephem, times_to_save) end From 00bd2fda710654f42f7806b35c70bd371260231a Mon Sep 17 00:00:00 2001 From: kanamaru-masanori Date: Wed, 22 Nov 2023 15:16:59 +0900 Subject: [PATCH 03/15] Remove an unnecessary argument `times_to_save` --- src/TPM.jl | 10 +++++----- test/TPM_Didymos.jl | 2 +- test/TPM_Ryugu.jl | 2 +- test/non-uniform_thermoparams.jl | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/TPM.jl b/src/TPM.jl index 5f712d6b..99df7581 100644 --- a/src/TPM.jl +++ b/src/TPM.jl @@ -388,7 +388,7 @@ Export the result of `SingleTPM` to CSV files. - Save the depths of the calculation nodes - Save README for the data file """ -function export_TPM_results(dirpath, result::SingleTPMResult, stpm::SingleTPM, ephem, times_to_save::Vector{Float64}) +function export_TPM_results(dirpath, result::SingleTPMResult, stpm::SingleTPM, ephem) df = DataFrame() df.time = ephem.time @@ -405,7 +405,7 @@ function export_TPM_results(dirpath, result::SingleTPMResult, stpm::SingleTPM, e CSV.write(joinpath(dirpath, "data.csv"), df) ##= Surface temperature =## - header = string.(times_to_save) + header = string.(result.times_to_save) CSV.write( joinpath(dirpath, "surf_temp.csv"), DataFrame(result.surf_temp, header) @@ -432,15 +432,15 @@ Export the result of `BinaryTPM` to CSV files. - `btpm` : Thermophysical model for a binary asteroid - `ephem` : Ephemerides """ -function export_TPM_results(dirpath, result::BinaryTPMResult, btpm::BinaryTPM, ephem, times_to_save::Vector{Float64}) +function export_TPM_results(dirpath, result::BinaryTPMResult, btpm::BinaryTPM, ephem) dirpath_pri = joinpath(dirpath, "pri") dirpath_sec = joinpath(dirpath, "sec") mkpath(dirpath_pri) mkpath(dirpath_sec) - export_TPM_results(dirpath_pri, result.pri, btpm.pri, ephem, times_to_save) - export_TPM_results(dirpath_sec, result.sec, btpm.sec, ephem, times_to_save) + export_TPM_results(dirpath_pri, result.pri, btpm.pri, ephem) + export_TPM_results(dirpath_sec, result.sec, btpm.sec, ephem) end diff --git a/test/TPM_Didymos.jl b/test/TPM_Didymos.jl index 731ee16d..0f14b416 100644 --- a/test/TPM_Didymos.jl +++ b/test/TPM_Didymos.jl @@ -148,5 +148,5 @@ ##= Save TPM result =## savedir = "TPM_Didymos" mkpath(savedir) - AsteroidThermoPhysicalModels.export_TPM_results(savedir, result, btpm, ephem, times_to_save) + AsteroidThermoPhysicalModels.export_TPM_results(savedir, result, btpm, ephem) end diff --git a/test/TPM_Ryugu.jl b/test/TPM_Ryugu.jl index b63f9e87..491827c9 100644 --- a/test/TPM_Ryugu.jl +++ b/test/TPM_Ryugu.jl @@ -104,5 +104,5 @@ ##= Save TPM result =## savedir = "TPM_Ryugu" mkpath(savedir) - AsteroidThermoPhysicalModels.export_TPM_results(savedir, result, stpm, ephem, times_to_save) + AsteroidThermoPhysicalModels.export_TPM_results(savedir, result, stpm, ephem) end diff --git a/test/non-uniform_thermoparams.jl b/test/non-uniform_thermoparams.jl index d5694324..1395dd67 100644 --- a/test/non-uniform_thermoparams.jl +++ b/test/non-uniform_thermoparams.jl @@ -117,5 +117,5 @@ ##= Save TPM result =##' savedir = "non-uniform_thermoparams" mkpath(savedir) - AsteroidThermoPhysicalModels.export_TPM_results(savedir, result, stpm, ephem, times_to_save) + AsteroidThermoPhysicalModels.export_TPM_results(savedir, result, stpm, ephem) end From 75769ef2572c927cf9152c3dcd432bc4a608f412 Mon Sep 17 00:00:00 2001 From: kanamaru-masanori Date: Wed, 22 Nov 2023 15:27:00 +0900 Subject: [PATCH 04/15] Update TPM.jl Add `times` in `SingleTPMResult` to store the time steps of the entire simulation. --- src/TPM.jl | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/TPM.jl b/src/TPM.jl index 99df7581..ab5fb814 100644 --- a/src/TPM.jl +++ b/src/TPM.jl @@ -228,6 +228,7 @@ Output data format for `SingleTPM` # Fields ## Saved at all time steps +- `times` : Timesteps, given the same vector as `ephem.time` [s] - `E_in` : Input energy per second on the whole surface [W] - `E_out` : Output enegey per second from the whole surface [W] - `E_cons` : Energy conservation ratio [-], ratio of total energy going out to total energy coming in in the last rotation cycle @@ -235,15 +236,16 @@ Output data format for `SingleTPM` - `torque` : Thermal torque on the asteroid [N ⋅ m] ## Saved only at the time steps desired by the user -- `times_to_save` : Timesteps to save temperature -- `surf_temp` : Surface temperature, a matrix in size of `(Ns, Nt)`. +- `times_to_save` : Timesteps to save temperature [s] +- `surf_temp` : Surface temperature [K], a matrix in size of `(Ns, Nt)`. - `Ns` : Number of faces - `Nt` : Number of time steps to save surface temperature -- `face_temp` : Temperature as a function of depth and time, `Dict` with face ID as key and a matrix `(Nz, Nt)` as an entry. +- `face_temp` : Temperature [K] as a function of depth [m] and time [s], `Dict` with face ID as key and a matrix `(Nz, Nt)` as an entry. - `Nz` : The number of the depth nodes - `Nt` : The number of time steps to save temperature """ struct SingleTPMResult + times ::Vector{Float64} E_in ::Vector{Float64} E_out ::Vector{Float64} E_cons ::Vector{Union{Float64, Missing}} @@ -277,7 +279,7 @@ function SingleTPMResult(stpm::SingleTPM, ephem, times_to_save::Vector{Float64}, nₛ => zeros(stpm.thermo_params.Nz, length(times_to_save)) for nₛ in face_ID ) - return SingleTPMResult(E_in, E_out, E_cons, force, torque, times_to_save, surf_temp, face_temp) + return SingleTPMResult(ephem.time, E_in, E_out, E_cons, force, torque, times_to_save, surf_temp, face_temp) end From 1f3993911230208bb89e0c2a6c9f46c88c32e7f0 Mon Sep 17 00:00:00 2001 From: kanamaru-masanori Date: Wed, 22 Nov 2023 16:04:13 +0900 Subject: [PATCH 05/15] Update TPM.jl Use `result.times` instead of `ephem.time` --- src/TPM.jl | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/TPM.jl b/src/TPM.jl index ab5fb814..5ac21d74 100644 --- a/src/TPM.jl +++ b/src/TPM.jl @@ -327,26 +327,26 @@ Save the results of TPM at the time step `nₜ` to `result`. - `ephem` : Ephemerides - `nₜ` : Time step to save data """ -function update_TPM_result!(result::SingleTPMResult, stpm::SingleTPM, ephem, nₜ::Integer, times_to_save::Vector{Float64}) +function update_TPM_result!(result::SingleTPMResult, stpm::SingleTPM, nₜ::Integer, times_to_save::Vector{Float64}) result.E_in[nₜ] = energy_in(stpm) result.E_out[nₜ] = energy_out(stpm) result.force[nₜ] = stpm.force result.torque[nₜ] = stpm.torque P = stpm.thermo_params.P # Rotation period - t = ephem.time[nₜ] # Current time - t₀ = ephem.time[begin] # Time at the beginning of the simulation + t = result.times[nₜ] # Current time + t₀ = result.times[begin] # Time at the beginning of the simulation if t > t₀ + P # Note that `E_cons` cannot be calculated during the first rotation - Nt_period = count(@. t - P ≤ ephem.time < t) # Number of time steps within the last rotation + nsteps_in_period = count(@. t - P ≤ result.times < t) # Number of time steps within the last rotation - ΣE_in = sum(result.E_in[n-1] * (ephem.time[n] - ephem.time[n-1]) for n in (nₜ - Nt_period + 1):nₜ) - ΣE_out = sum(result.E_out[n-1] * (ephem.time[n] - ephem.time[n-1]) for n in (nₜ - Nt_period + 1):nₜ) + ΣE_in = sum(result.E_in[n-1] * (result.times[n] - result.times[n-1]) for n in (nₜ - nsteps_in_period + 1):nₜ) + ΣE_out = sum(result.E_out[n-1] * (result.times[n] - result.times[n-1]) for n in (nₜ - nsteps_in_period + 1):nₜ) result.E_cons[nₜ] = ΣE_out / ΣE_in end - if t in times_to_save # In the step of saving temperature + if t in result.times_to_save # In the step of saving temperature nₜ_save = findfirst(isequal(t), times_to_save) result.surf_temp[:, nₜ_save] .= surface_temperature(stpm) @@ -369,9 +369,9 @@ Save the results of TPM at the time step `nₜ` to `result`. - `ephem` : Ephemerides - `nₜ` : Time step """ -function update_TPM_result!(result::BinaryTPMResult, btpm::BinaryTPM, ephem, nₜ::Integer, times_to_save::Vector{Float64}) - update_TPM_result!(result.pri, btpm.pri, ephem, nₜ, times_to_save) - update_TPM_result!(result.sec, btpm.sec, ephem, nₜ, times_to_save) +function update_TPM_result!(result::BinaryTPMResult, btpm::BinaryTPM, nₜ::Integer, times_to_save::Vector{Float64}) + update_TPM_result!(result.pri, btpm.pri, nₜ, times_to_save) + update_TPM_result!(result.sec, btpm.sec, nₜ, times_to_save) end @@ -579,7 +579,7 @@ function run_TPM!(stpm::SingleTPM, ephem, times_to_save::Vector{Float64}, face_I update_thermal_force!(stpm) - update_TPM_result!(result, stpm, ephem, nₜ, times_to_save) # Save data + update_TPM_result!(result, stpm, nₜ, times_to_save) # Save data ## Update the progress meter if show_progress @@ -644,7 +644,7 @@ function run_TPM!(btpm::BinaryTPM, ephem, times_to_save::Vector{Float64}, face_I update_thermal_force!(btpm) - update_TPM_result!(result, btpm, ephem, nₜ, times_to_save) # Save data + update_TPM_result!(result, btpm, nₜ, times_to_save) # Save data ## Update the progress meter if show_progress From 94af73a876de497b6fbe2c8c3a0f17cccb883b1a Mon Sep 17 00:00:00 2001 From: kanamaru-masanori Date: Wed, 22 Nov 2023 16:07:05 +0900 Subject: [PATCH 06/15] Use `result.times` - Use `result.times` instead of `ephem.time` - Remove unnecessary arguments --- src/TPM.jl | 10 +++++----- test/TPM_Didymos.jl | 2 +- test/TPM_Ryugu.jl | 2 +- test/non-uniform_thermoparams.jl | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/TPM.jl b/src/TPM.jl index 5ac21d74..473a00b4 100644 --- a/src/TPM.jl +++ b/src/TPM.jl @@ -390,10 +390,10 @@ Export the result of `SingleTPM` to CSV files. - Save the depths of the calculation nodes - Save README for the data file """ -function export_TPM_results(dirpath, result::SingleTPMResult, stpm::SingleTPM, ephem) +function export_TPM_results(dirpath, result::SingleTPMResult, stpm::SingleTPM) df = DataFrame() - df.time = ephem.time + df.time = result.times df.E_in = result.E_in df.E_out = result.E_out df.E_cons = result.E_cons @@ -434,15 +434,15 @@ Export the result of `BinaryTPM` to CSV files. - `btpm` : Thermophysical model for a binary asteroid - `ephem` : Ephemerides """ -function export_TPM_results(dirpath, result::BinaryTPMResult, btpm::BinaryTPM, ephem) +function export_TPM_results(dirpath, result::BinaryTPMResult, btpm::BinaryTPM) dirpath_pri = joinpath(dirpath, "pri") dirpath_sec = joinpath(dirpath, "sec") mkpath(dirpath_pri) mkpath(dirpath_sec) - export_TPM_results(dirpath_pri, result.pri, btpm.pri, ephem) - export_TPM_results(dirpath_sec, result.sec, btpm.sec, ephem) + export_TPM_results(dirpath_pri, result.pri, btpm.pri) + export_TPM_results(dirpath_sec, result.sec, btpm.sec) end diff --git a/test/TPM_Didymos.jl b/test/TPM_Didymos.jl index 0f14b416..9c757f06 100644 --- a/test/TPM_Didymos.jl +++ b/test/TPM_Didymos.jl @@ -148,5 +148,5 @@ ##= Save TPM result =## savedir = "TPM_Didymos" mkpath(savedir) - AsteroidThermoPhysicalModels.export_TPM_results(savedir, result, btpm, ephem) + AsteroidThermoPhysicalModels.export_TPM_results(savedir, result, btpm) end diff --git a/test/TPM_Ryugu.jl b/test/TPM_Ryugu.jl index 491827c9..a8a6021d 100644 --- a/test/TPM_Ryugu.jl +++ b/test/TPM_Ryugu.jl @@ -104,5 +104,5 @@ ##= Save TPM result =## savedir = "TPM_Ryugu" mkpath(savedir) - AsteroidThermoPhysicalModels.export_TPM_results(savedir, result, stpm, ephem) + AsteroidThermoPhysicalModels.export_TPM_results(savedir, result, stpm) end diff --git a/test/non-uniform_thermoparams.jl b/test/non-uniform_thermoparams.jl index 1395dd67..a70b6500 100644 --- a/test/non-uniform_thermoparams.jl +++ b/test/non-uniform_thermoparams.jl @@ -117,5 +117,5 @@ ##= Save TPM result =##' savedir = "non-uniform_thermoparams" mkpath(savedir) - AsteroidThermoPhysicalModels.export_TPM_results(savedir, result, stpm, ephem) + AsteroidThermoPhysicalModels.export_TPM_results(savedir, result, stpm) end From d6e6bb549660e86c664f95e1abae24d6cb6ef03b Mon Sep 17 00:00:00 2001 From: kanamaru-masanori Date: Wed, 22 Nov 2023 16:13:19 +0900 Subject: [PATCH 07/15] Update TPM.jl - Use `result.times_to_save` --- src/TPM.jl | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/TPM.jl b/src/TPM.jl index 473a00b4..2a9d9489 100644 --- a/src/TPM.jl +++ b/src/TPM.jl @@ -327,7 +327,7 @@ Save the results of TPM at the time step `nₜ` to `result`. - `ephem` : Ephemerides - `nₜ` : Time step to save data """ -function update_TPM_result!(result::SingleTPMResult, stpm::SingleTPM, nₜ::Integer, times_to_save::Vector{Float64}) +function update_TPM_result!(result::SingleTPMResult, stpm::SingleTPM, nₜ::Integer) result.E_in[nₜ] = energy_in(stpm) result.E_out[nₜ] = energy_out(stpm) result.force[nₜ] = stpm.force @@ -347,7 +347,7 @@ function update_TPM_result!(result::SingleTPMResult, stpm::SingleTPM, nₜ::Inte end if t in result.times_to_save # In the step of saving temperature - nₜ_save = findfirst(isequal(t), times_to_save) + nₜ_save = findfirst(isequal(t), result.times_to_save) result.surf_temp[:, nₜ_save] .= surface_temperature(stpm) @@ -369,9 +369,9 @@ Save the results of TPM at the time step `nₜ` to `result`. - `ephem` : Ephemerides - `nₜ` : Time step """ -function update_TPM_result!(result::BinaryTPMResult, btpm::BinaryTPM, nₜ::Integer, times_to_save::Vector{Float64}) - update_TPM_result!(result.pri, btpm.pri, nₜ, times_to_save) - update_TPM_result!(result.sec, btpm.sec, nₜ, times_to_save) +function update_TPM_result!(result::BinaryTPMResult, btpm::BinaryTPM, nₜ::Integer) + update_TPM_result!(result.pri, btpm.pri, nₜ) + update_TPM_result!(result.sec, btpm.sec, nₜ) end @@ -579,7 +579,7 @@ function run_TPM!(stpm::SingleTPM, ephem, times_to_save::Vector{Float64}, face_I update_thermal_force!(stpm) - update_TPM_result!(result, stpm, nₜ, times_to_save) # Save data + update_TPM_result!(result, stpm, nₜ) # Save data ## Update the progress meter if show_progress @@ -644,7 +644,7 @@ function run_TPM!(btpm::BinaryTPM, ephem, times_to_save::Vector{Float64}, face_I update_thermal_force!(btpm) - update_TPM_result!(result, btpm, nₜ, times_to_save) # Save data + update_TPM_result!(result, btpm, nₜ) # Save data ## Update the progress meter if show_progress From 3454e287dd5fb0fbc515fbb794a1b6d16f6c43c5 Mon Sep 17 00:00:00 2001 From: kanamaru-masanori Date: Wed, 22 Nov 2023 21:20:05 +0900 Subject: [PATCH 08/15] Remove unnecessary arguments --- src/TPM.jl | 16 ++++++---------- test/TPM_Didymos.jl | 2 +- test/TPM_Ryugu.jl | 2 +- test/non-uniform_thermoparams.jl | 2 +- 4 files changed, 9 insertions(+), 13 deletions(-) diff --git a/src/TPM.jl b/src/TPM.jl index 2a9d9489..39016c8b 100644 --- a/src/TPM.jl +++ b/src/TPM.jl @@ -376,21 +376,19 @@ end """ - export_TPM_results(dirpath, result::SingleTPMResult, stpm::SingleTPM, ephem) + export_TPM_results(dirpath, result::SingleTPMResult) Export the result of `SingleTPM` to CSV files. # Arguments - `dirpath` : Path to the directory to save CSV files - `result` : Output data format for `SingleTPM` -- `stpm` : Thermophysical model for a single asteroid -- `ephem` : Ephemerides # TO DO - Save the depths of the calculation nodes - Save README for the data file """ -function export_TPM_results(dirpath, result::SingleTPMResult, stpm::SingleTPM) +function export_TPM_results(dirpath, result::SingleTPMResult) df = DataFrame() df.time = result.times @@ -424,25 +422,23 @@ end """ - export_TPM_results(filepath, result::BinaryTPMResult, stpm::BinaryTPM, ephem) + export_TPM_results(filepath, result::BinaryTPMResult) Export the result of `BinaryTPM` to CSV files. # Arguments - `dirpath` : Path to the directory to save CSV files - `result` : Output data format for `BinaryTPM` -- `btpm` : Thermophysical model for a binary asteroid -- `ephem` : Ephemerides """ -function export_TPM_results(dirpath, result::BinaryTPMResult, btpm::BinaryTPM) +function export_TPM_results(dirpath, result::BinaryTPMResult) dirpath_pri = joinpath(dirpath, "pri") dirpath_sec = joinpath(dirpath, "sec") mkpath(dirpath_pri) mkpath(dirpath_sec) - export_TPM_results(dirpath_pri, result.pri, btpm.pri) - export_TPM_results(dirpath_sec, result.sec, btpm.sec) + export_TPM_results(dirpath_pri, result.pri) + export_TPM_results(dirpath_sec, result.sec) end diff --git a/test/TPM_Didymos.jl b/test/TPM_Didymos.jl index 9c757f06..5dd68804 100644 --- a/test/TPM_Didymos.jl +++ b/test/TPM_Didymos.jl @@ -148,5 +148,5 @@ ##= Save TPM result =## savedir = "TPM_Didymos" mkpath(savedir) - AsteroidThermoPhysicalModels.export_TPM_results(savedir, result, btpm) + AsteroidThermoPhysicalModels.export_TPM_results(savedir, result) end diff --git a/test/TPM_Ryugu.jl b/test/TPM_Ryugu.jl index a8a6021d..36673cfd 100644 --- a/test/TPM_Ryugu.jl +++ b/test/TPM_Ryugu.jl @@ -104,5 +104,5 @@ ##= Save TPM result =## savedir = "TPM_Ryugu" mkpath(savedir) - AsteroidThermoPhysicalModels.export_TPM_results(savedir, result, stpm) + AsteroidThermoPhysicalModels.export_TPM_results(savedir, result) end diff --git a/test/non-uniform_thermoparams.jl b/test/non-uniform_thermoparams.jl index a70b6500..ad18474c 100644 --- a/test/non-uniform_thermoparams.jl +++ b/test/non-uniform_thermoparams.jl @@ -117,5 +117,5 @@ ##= Save TPM result =##' savedir = "non-uniform_thermoparams" mkpath(savedir) - AsteroidThermoPhysicalModels.export_TPM_results(savedir, result, stpm) + AsteroidThermoPhysicalModels.export_TPM_results(savedir, result) end From 15282479ca7afd9827b2df34ce6f940edc12a4f1 Mon Sep 17 00:00:00 2001 From: kanamaru-masanori Date: Thu, 23 Nov 2023 02:08:38 +0900 Subject: [PATCH 09/15] Update TPM.jl - Add `depth_nodes` in `SingleTPMResult` to store the depths of the calculation nodes for the 1-D heat conduction equation. --- src/TPM.jl | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/TPM.jl b/src/TPM.jl index 39016c8b..19f5c4cf 100644 --- a/src/TPM.jl +++ b/src/TPM.jl @@ -237,6 +237,7 @@ Output data format for `SingleTPM` ## Saved only at the time steps desired by the user - `times_to_save` : Timesteps to save temperature [s] +- `depth_nodes` : Depths of the calculation nodes for 1-D heat conduction [m], a vector of size `Nz` - `surf_temp` : Surface temperature [K], a matrix in size of `(Ns, Nt)`. - `Ns` : Number of faces - `Nt` : Number of time steps to save surface temperature @@ -253,6 +254,7 @@ struct SingleTPMResult torque ::Vector{SVector{3, Float64}} times_to_save ::Vector{Float64} + depth_nodes ::Vector{Float64} surf_temp ::Matrix{Float64} face_temp ::Dict{Int, Matrix{Float64}} end @@ -274,12 +276,13 @@ function SingleTPMResult(stpm::SingleTPM, ephem, times_to_save::Vector{Float64}, force = zeros(SVector{3, Float64}, length(ephem.time)) torque = zeros(SVector{3, Float64}, length(ephem.time)) + depth_nodes = stpm.thermo_params.Δz * (0:stpm.thermo_params.Nz-1) surf_temp = zeros(length(stpm.shape.faces), length(times_to_save)) face_temp = Dict{Int, Matrix{Float64}}( nₛ => zeros(stpm.thermo_params.Nz, length(times_to_save)) for nₛ in face_ID ) - return SingleTPMResult(ephem.time, E_in, E_out, E_cons, force, torque, times_to_save, surf_temp, face_temp) + return SingleTPMResult(ephem.time, E_in, E_out, E_cons, force, torque, times_to_save, depth_nodes, surf_temp, face_temp) end @@ -405,18 +408,19 @@ function export_TPM_results(dirpath, result::SingleTPMResult) CSV.write(joinpath(dirpath, "data.csv"), df) ##= Surface temperature =## + filepath = joinpath(dirpath, "surf_temp.csv") header = string.(result.times_to_save) - CSV.write( - joinpath(dirpath, "surf_temp.csv"), - DataFrame(result.surf_temp, header) - ) + df = DataFrame(result.surf_temp, header) + + CSV.write(filepath, df) ##= Subsurface temperature =## for (nₛ, temp) in result.face_temp - CSV.write( - joinpath(dirpath, "face_temp_$(lpad(nₛ, 7, '0')).csv"), - DataFrame(temp, header) - ) + filepath = joinpath(dirpath, "face_temp_$(lpad(nₛ, 7, '0')).csv") + header = string.(result.times_to_save) + df = hcat(DataFrame(depth_nodes=result.depth_nodes), DataFrame(temp, header)) + + CSV.write(filepath, df) end end @@ -590,7 +594,7 @@ function run_TPM!(stpm::SingleTPM, ephem, times_to_save::Vector{Float64}, face_I Δt = ephem.time[nₜ+1] - ephem.time[nₜ] update_temperature!(stpm, Δt) end - + return result end From b15a728387ba921c48e0cc4d5cb3b2922298beea Mon Sep 17 00:00:00 2001 From: kanamaru-masanori Date: Thu, 23 Nov 2023 20:19:35 +0900 Subject: [PATCH 10/15] Update TPM.jl Just a cleanup --- src/TPM.jl | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/TPM.jl b/src/TPM.jl index 19f5c4cf..874a4415 100644 --- a/src/TPM.jl +++ b/src/TPM.jl @@ -267,19 +267,22 @@ Outer constructor of `SingleTPMResult` - `stpm` : Thermophysical model for a single asteroid - `ephem` : Ephemerides - `times_to_save` : Timesteps to save temperature -- `face_ID` : Face indices where to save subsurface temperature +- `face_ID` : Face indices to save subsurface temperature """ function SingleTPMResult(stpm::SingleTPM, ephem, times_to_save::Vector{Float64}, face_ID::Vector{Int}) - E_in = zeros(length(ephem.time)) - E_out = zeros(length(ephem.time)) - E_cons = Vector{Union{Float64, Missing}}(missing, length(ephem.time)) - force = zeros(SVector{3, Float64}, length(ephem.time)) - torque = zeros(SVector{3, Float64}, length(ephem.time)) + nsteps = length(ephem.time) + nsteps_to_save = length(times_to_save) + + E_in = zeros(nsteps) + E_out = zeros(nsteps) + E_cons = Vector{Union{Float64, Missing}}(missing, nsteps) + force = zeros(SVector{3, Float64}, nsteps) + torque = zeros(SVector{3, Float64}, nsteps) depth_nodes = stpm.thermo_params.Δz * (0:stpm.thermo_params.Nz-1) - surf_temp = zeros(length(stpm.shape.faces), length(times_to_save)) + surf_temp = zeros(length(stpm.shape.faces), nsteps_to_save) face_temp = Dict{Int, Matrix{Float64}}( - nₛ => zeros(stpm.thermo_params.Nz, length(times_to_save)) for nₛ in face_ID + nₛ => zeros(stpm.thermo_params.Nz, nsteps_to_save) for nₛ in face_ID ) return SingleTPMResult(ephem.time, E_in, E_out, E_cons, force, torque, times_to_save, depth_nodes, surf_temp, face_temp) @@ -308,8 +311,8 @@ Outer constructor of `BinaryTPMResult` - `btpm` : Thermophysical model for a binary asteroid - `ephem` : Ephemerides - `times_to_save` : Timesteps to save temperature (Common to both the primary and the secondary) -- `face_ID_pri` : Face indices at which you want to save temperature as a function of depth for the primary -- `face_ID_sec` : Face indices at which you want to save temperature as a function of depth for the secondary +- `face_ID_pri` : Face indices to save subsurface temperature of the primary +- `face_ID_sec` : Face indices to save subsurface temperature of the secondary """ function BinaryTPMResult(btpm::BinaryTPM, ephem, times_to_save::Vector{Float64}, face_ID_pri::Vector{Int}, face_ID_sec::Vector{Int}) result_pri = SingleTPMResult(btpm.pri, ephem, times_to_save, face_ID_pri) @@ -320,14 +323,13 @@ end """ - update_TPM_result!(result::SingleTPMResult, stpm::SingleTPM, ephem, nₜ::Integer) + update_TPM_result!(result::SingleTPMResult, stpm::SingleTPM, nₜ::Integer) Save the results of TPM at the time step `nₜ` to `result`. # Arguments - `result` : Output data format for `SingleTPM` - `stpm` : Thermophysical model for a single asteroid -- `ephem` : Ephemerides - `nₜ` : Time step to save data """ function update_TPM_result!(result::SingleTPMResult, stpm::SingleTPM, nₜ::Integer) @@ -337,8 +339,8 @@ function update_TPM_result!(result::SingleTPMResult, stpm::SingleTPM, nₜ::Inte result.torque[nₜ] = stpm.torque P = stpm.thermo_params.P # Rotation period - t = result.times[nₜ] # Current time - t₀ = result.times[begin] # Time at the beginning of the simulation + t = result.times[nₜ] # Current time + t₀ = result.times[begin] # Time at the beginning of the simulation if t > t₀ + P # Note that `E_cons` cannot be calculated during the first rotation nsteps_in_period = count(@. t - P ≤ result.times < t) # Number of time steps within the last rotation From 06806e10b993e3a357835772511dd402be76dd92 Mon Sep 17 00:00:00 2001 From: kanamaru-masanori Date: Thu, 23 Nov 2023 20:27:40 +0900 Subject: [PATCH 11/15] Just a cleanup of test scripts --- test/TPM_Didymos.jl | 8 ++++---- test/TPM_Ryugu.jl | 8 ++++---- test/non-uniform_thermoparams.jl | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/test/TPM_Didymos.jl b/test/TPM_Didymos.jl index 5dd68804..38c2d306 100644 --- a/test/TPM_Didymos.jl +++ b/test/TPM_Didymos.jl @@ -52,9 +52,9 @@ et_begin = SPICE.utc2et("2027-02-18T00:00:00") # Start time of TPM et_end = et_begin + 2P₂ # End time of TPM - nsteps_in_rotation = 72 # Number of steps in one rotation period - step = P₂ / nsteps_in_rotation # Time step of TPM - et_range = et_begin : step : et_end + nsteps_in_period = 72 # Number of steps in one rotation period + Δt = P₂ / nsteps_in_period # Time step of TPM + et_range = et_begin : Δt : et_end """ - `time` : Ephemeris times @@ -139,7 +139,7 @@ AsteroidThermoPhysicalModels.init_temperature!(btpm, 200.) ##= Run TPM =## - times_to_save = ephem.time[end-nsteps_in_rotation:end] # Save temperature during the final rotation + times_to_save = ephem.time[end-nsteps_in_period:end] # Save temperature during the final rotation face_ID_pri = [1, 2, 3, 4, 10] # Face indices to save subsurface temperature of the primary face_ID_sec = [1, 2, 3, 4, 20] # Face indices to save subsurface temperature of the secondary diff --git a/test/TPM_Ryugu.jl b/test/TPM_Ryugu.jl index 36673cfd..7893bbd4 100644 --- a/test/TPM_Ryugu.jl +++ b/test/TPM_Ryugu.jl @@ -43,9 +43,9 @@ et_begin = SPICE.utc2et("2018-07-01T00:00:00") # Start time of TPM et_end = et_begin + 2P # End time of TPM - nsteps_in_rotation = 72 # Number of steps in one rotation period - step = P / nsteps_in_rotation # Time step of TPM - et_range = et_begin : step : et_end + nsteps_in_period = 72 # Number of steps in one rotation period + Δt = P / nsteps_in_period # Time step of TPM + et_range = et_begin : Δt : et_end """ - `time` : Ephemeris times @@ -96,7 +96,7 @@ AsteroidThermoPhysicalModels.init_temperature!(stpm, 200) ##= Run TPM =## - times_to_save = ephem.time[end-nsteps_in_rotation:end] # Save temperature during the final rotation + times_to_save = ephem.time[end-nsteps_in_period:end] # Save temperature during the final rotation face_ID = [1, 2, 3, 4, 10] # Face indices to save subsurface temperature result = AsteroidThermoPhysicalModels.run_TPM!(stpm, ephem, times_to_save, face_ID) diff --git a/test/non-uniform_thermoparams.jl b/test/non-uniform_thermoparams.jl index ad18474c..5190c0ec 100644 --- a/test/non-uniform_thermoparams.jl +++ b/test/non-uniform_thermoparams.jl @@ -45,9 +45,9 @@ et_begin = SPICE.utc2et("2018-07-01T00:00:00") # Start time of TPM et_end = et_begin + 2P # End time of TPM - nsteps_in_rotation = 120 # Number of steps in one rotation period - step = P / nsteps_in_rotation # Time step of TPM - et_range = et_begin : step : et_end + nsteps_in_period = 120 # Number of steps in one rotation period + Δt = P / nsteps_in_period # Time step of TPM + et_range = et_begin : Δt : et_end """ - `time` : Ephemeris times @@ -109,7 +109,7 @@ AsteroidThermoPhysicalModels.init_temperature!(stpm, 200) ##= Run TPM =## - times_to_save = ephem.time[end-nsteps_in_rotation:end] # Save temperature during the final rotation + times_to_save = ephem.time[end-nsteps_in_period:end] # Save temperature during the final rotation face_ID = [1, 2, 3, 4, 10] # Face indices to save subsurface temperature result = AsteroidThermoPhysicalModels.run_TPM!(stpm, ephem, times_to_save, face_ID) From 0e97d3db5d69c389d90810abe41c434f945cfccb Mon Sep 17 00:00:00 2001 From: "M. Kanamaru" Date: Sat, 2 Dec 2023 16:49:10 +0900 Subject: [PATCH 12/15] Update test/TPM_Didymos.jl Co-authored-by: Yuto Horikawa --- test/TPM_Didymos.jl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/TPM_Didymos.jl b/test/TPM_Didymos.jl index 38c2d306..2bcf9e1f 100644 --- a/test/TPM_Didymos.jl +++ b/test/TPM_Didymos.jl @@ -53,8 +53,7 @@ et_end = et_begin + 2P₂ # End time of TPM nsteps_in_period = 72 # Number of steps in one rotation period - Δt = P₂ / nsteps_in_period # Time step of TPM - et_range = et_begin : Δt : et_end + et_range = range(et_begin, et_end, length=nsteps_in_period+1) """ - `time` : Ephemeris times From 75add68d008c8436776c784bb949ca79ec4e1b0f Mon Sep 17 00:00:00 2001 From: "M. Kanamaru" Date: Sat, 2 Dec 2023 16:50:15 +0900 Subject: [PATCH 13/15] Update test/TPM_Ryugu.jl Co-authored-by: Yuto Horikawa --- test/TPM_Ryugu.jl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/TPM_Ryugu.jl b/test/TPM_Ryugu.jl index 7893bbd4..b6141f45 100644 --- a/test/TPM_Ryugu.jl +++ b/test/TPM_Ryugu.jl @@ -44,8 +44,7 @@ et_end = et_begin + 2P # End time of TPM nsteps_in_period = 72 # Number of steps in one rotation period - Δt = P / nsteps_in_period # Time step of TPM - et_range = et_begin : Δt : et_end + et_range = range(et_begin, et_end, length=nsteps_in_period+1) """ - `time` : Ephemeris times From de0801d6330219a8979bee6c7a0c289af270bbbd Mon Sep 17 00:00:00 2001 From: "M. Kanamaru" Date: Sat, 2 Dec 2023 16:50:28 +0900 Subject: [PATCH 14/15] Update test/non-uniform_thermoparams.jl Co-authored-by: Yuto Horikawa --- test/non-uniform_thermoparams.jl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/non-uniform_thermoparams.jl b/test/non-uniform_thermoparams.jl index 5190c0ec..d6f72f9a 100644 --- a/test/non-uniform_thermoparams.jl +++ b/test/non-uniform_thermoparams.jl @@ -46,8 +46,7 @@ et_end = et_begin + 2P # End time of TPM nsteps_in_period = 120 # Number of steps in one rotation period - Δt = P / nsteps_in_period # Time step of TPM - et_range = et_begin : Δt : et_end + et_range = range(et_begin, et_end, length=nsteps_in_period+1) """ - `time` : Ephemeris times From 96b2b87a0a4722e5f6b1ed0250d425ec8e2de12a Mon Sep 17 00:00:00 2001 From: kanamaru-masanori Date: Sat, 2 Dec 2023 17:36:02 +0900 Subject: [PATCH 15/15] Update test scripts Use the `range` function for `et_range` --- test/TPM_Didymos.jl | 11 ++++++----- test/TPM_Ryugu.jl | 14 ++++++++------ test/heat_conduction_1D.jl | 5 +---- test/non-uniform_thermoparams.jl | 14 ++++++++------ 4 files changed, 23 insertions(+), 21 deletions(-) diff --git a/test/TPM_Didymos.jl b/test/TPM_Didymos.jl index 2bcf9e1f..3ca75320 100644 --- a/test/TPM_Didymos.jl +++ b/test/TPM_Didymos.jl @@ -49,11 +49,12 @@ P₁ = SPICE.convrt(2.2593, "hours", "seconds") # Rotation period of Didymos P₂ = SPICE.convrt(11.93 , "hours", "seconds") # Rotation period of Dimorphos - et_begin = SPICE.utc2et("2027-02-18T00:00:00") # Start time of TPM - et_end = et_begin + 2P₂ # End time of TPM + ncycles = 2 # Number of cycles to perform TPM + nsteps_in_cycle = 72 # Number of time steps in one rotation period - nsteps_in_period = 72 # Number of steps in one rotation period - et_range = range(et_begin, et_end, length=nsteps_in_period+1) + et_begin = SPICE.utc2et("2027-02-18T00:00:00") # Start time of TPM + et_end = et_begin + P₂ * ncycles # End time of TPM + et_range = range(et_begin, et_end; length=nsteps_in_cycle*ncycles+1) """ - `time` : Ephemeris times @@ -138,7 +139,7 @@ AsteroidThermoPhysicalModels.init_temperature!(btpm, 200.) ##= Run TPM =## - times_to_save = ephem.time[end-nsteps_in_period:end] # Save temperature during the final rotation + times_to_save = ephem.time[end-nsteps_in_cycle:end] # Save temperature during the final rotation face_ID_pri = [1, 2, 3, 4, 10] # Face indices to save subsurface temperature of the primary face_ID_sec = [1, 2, 3, 4, 20] # Face indices to save subsurface temperature of the secondary diff --git a/test/TPM_Ryugu.jl b/test/TPM_Ryugu.jl index b6141f45..0307f2f4 100644 --- a/test/TPM_Ryugu.jl +++ b/test/TPM_Ryugu.jl @@ -39,12 +39,14 @@ end ##= Ephemerides =## - P = SPICE.convrt(7.63262, "hours", "seconds") # Rotation period of Ryugu - et_begin = SPICE.utc2et("2018-07-01T00:00:00") # Start time of TPM - et_end = et_begin + 2P # End time of TPM + P = SPICE.convrt(7.63262, "hours", "seconds") # Rotation period of Ryugu - nsteps_in_period = 72 # Number of steps in one rotation period - et_range = range(et_begin, et_end, length=nsteps_in_period+1) + ncycles = 2 # Number of cycles to perform TPM + nsteps_in_cycle = 72 # Number of time steps in one rotation period + + et_begin = SPICE.utc2et("2018-07-01T00:00:00") # Start time of TPM + et_end = et_begin + P * ncycles # End time of TPM + et_range = range(et_begin, et_end; length=nsteps_in_cycle*ncycles+1) """ - `time` : Ephemeris times @@ -95,7 +97,7 @@ AsteroidThermoPhysicalModels.init_temperature!(stpm, 200) ##= Run TPM =## - times_to_save = ephem.time[end-nsteps_in_period:end] # Save temperature during the final rotation + times_to_save = ephem.time[end-nsteps_in_cycle:end] # Save temperature during the final rotation face_ID = [1, 2, 3, 4, 10] # Face indices to save subsurface temperature result = AsteroidThermoPhysicalModels.run_TPM!(stpm, ephem, times_to_save, face_ID) diff --git a/test/heat_conduction_1D.jl b/test/heat_conduction_1D.jl index 1ca25568..f2635abd 100644 --- a/test/heat_conduction_1D.jl +++ b/test/heat_conduction_1D.jl @@ -12,10 +12,7 @@ shape = AsteroidThermoPhysicalModels.load_shape_obj(path_obj) ##= Seeting of time step =## - et_begin = 0.0 - et_end = 1.0 - step = 0.4e-4 - et_range = et_begin : step : et_end + et_range = range(0.0, 1.0; step=0.4e-4) ephem = ( time = collect(et_range), diff --git a/test/non-uniform_thermoparams.jl b/test/non-uniform_thermoparams.jl index d6f72f9a..ee32911e 100644 --- a/test/non-uniform_thermoparams.jl +++ b/test/non-uniform_thermoparams.jl @@ -41,12 +41,14 @@ end ##= Ephemerides =## - P = SPICE.convrt(7.63262, "hours", "seconds") # Rotation period of Ryugu - et_begin = SPICE.utc2et("2018-07-01T00:00:00") # Start time of TPM - et_end = et_begin + 2P # End time of TPM + P = SPICE.convrt(7.63262, "hours", "seconds") # Rotation period of Ryugu - nsteps_in_period = 120 # Number of steps in one rotation period - et_range = range(et_begin, et_end, length=nsteps_in_period+1) + ncycles = 2 # Number of cycles to perform TPM + nsteps_in_cycle = 120 # Number of time steps in one rotation period + + et_begin = SPICE.utc2et("2018-07-01T00:00:00") # Start time of TPM + et_end = et_begin + P * ncycles # End time of TPM + et_range = range(et_begin, et_end; length=nsteps_in_cycle*ncycles+1) """ - `time` : Ephemeris times @@ -108,7 +110,7 @@ AsteroidThermoPhysicalModels.init_temperature!(stpm, 200) ##= Run TPM =## - times_to_save = ephem.time[end-nsteps_in_period:end] # Save temperature during the final rotation + times_to_save = ephem.time[end-nsteps_in_cycle:end] # Save temperature during the final rotation face_ID = [1, 2, 3, 4, 10] # Face indices to save subsurface temperature result = AsteroidThermoPhysicalModels.run_TPM!(stpm, ephem, times_to_save, face_ID)