Skip to content

Commit

Permalink
Merge pull request #29 from mochell/12-remove-mtk-completely
Browse files Browse the repository at this point in the history
Removed Modeling toolkit from all core modules and updated basic tests
  • Loading branch information
mochell authored Jul 7, 2024
2 parents f0110e2 + 96feefc commit 2f0c987
Show file tree
Hide file tree
Showing 15 changed files with 91 additions and 246 deletions.
1 change: 0 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ JLD2 = "033835bb-8acc-5ee8-8aae-3f567f8a3819"
Juno = "e5e0dc1b-0480-54bc-9374-aad01c23163d"
LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
ModelingToolkit = "961ee093-0014-501f-94e3-6117800e7a78"
NCDatasets = "85f8d34a-cbdd-5861-8df4-14fed0d494ab"
Oceananigans = "9e8cae18-63c1-5223-a75c-80ca9d6e9a09"
OrderedCollections = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
Expand Down
2 changes: 1 addition & 1 deletion examples/example_eq_v3.jl → examples/_example_eq_v3.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ using Setfield
using Statistics

using JLD2, Printf,IfElse
using ModelingToolkit: Num, @unpack, @register_symbolic, Symbolics, @named, ODESystem
#using ModelingToolkit: Num, @unpack, @register_symbolic, Symbolics, @named, ODESystem

# %%
#push!(LOAD_PATH, joinpath(pwd(), "code/"))
Expand Down
2 changes: 1 addition & 1 deletion examples/example_eq_v4.jl → examples/_example_eq_v4.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ using Setfield
using Statistics

using JLD2, Printf,IfElse
using ModelingToolkit: Num, @unpack, @register_symbolic, Symbolics, @named, ODESystem
# using ModelingToolkit: Num, @unpack, @register_symbolic, Symbolics, @named, ODESystem

# %%

Expand Down
117 changes: 0 additions & 117 deletions examples/example_1D.jl

This file was deleted.

45 changes: 22 additions & 23 deletions src/Models/WaveGrowthModels1D.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ export WaveGrowth1D
export fields, reset_boundary!, show

using ...Architectures
using ModelingToolkit: get_states, ODESystem


#using core_1D: MarkedParticleInstance
Expand Down Expand Up @@ -221,28 +220,28 @@ function reset_boundary!(model::WaveGrowth1D)
end


function Base.show(io::IO, ow::WaveGrowth1D)

if ow.ODEsystem isa ODESystem
sys_print = get_states(ow.ODEsystem)
else
sys_print = ow.ODEsystem
end

print(io, "WaveGrowth1D ", "\n",
"├── grid: ", ow.grid, "\n",
"├── layers: ", ow.layers, "\n",
"├── clock: ", ow.clock,
"├── State: ", size(ow.State), "\n",
"├── ParticleCollection size: ", length(ow.ParticleCollection), "\n",
"├── ODEs \n",
"| ├── System: ", sys_print, "\n",
"| ├── Defaults: ", ow.ODEdefaults, "\n",
"| └── Settings: \n", ow.ODEsettings, "\n",
"├── winds ", ow.winds, "\n",
"├── currents ", ow.currents, "\n",
"└── Perdiodic Boundary ", ow.periodic_boundary, "\n")
end
# function Base.show(io::IO, ow::WaveGrowth1D)

# if ow.ODEsystem isa ODESystem
# sys_print = get_states(ow.ODEsystem)
# else
# sys_print = ow.ODEsystem
# end

# print(io, "WaveGrowth1D ", "\n",
# "├── grid: ", ow.grid, "\n",
# "├── layers: ", ow.layers, "\n",
# "├── clock: ", ow.clock,
# "├── State: ", size(ow.State), "\n",
# "├── ParticleCollection size: ", length(ow.ParticleCollection), "\n",
# "├── ODEs \n",
# "| ├── System: ", sys_print, "\n",
# "| ├── Defaults: ", ow.ODEdefaults, "\n",
# "| └── Settings: \n", ow.ODEsettings, "\n",
# "├── winds ", ow.winds, "\n",
# "├── currents ", ow.currents, "\n",
# "└── Perdiodic Boundary ", ow.periodic_boundary, "\n")
# end



Expand Down
7 changes: 1 addition & 6 deletions src/Models/WaveGrowthModels2D.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ export fields

using ...Architectures

using ModelingToolkit: get_states, ODESystem

#using core_1D: MarkedParticleInstance
using ...ParticleMesh: OneDGrid, OneDGridNotes, TwoDGrid, TwoDGridNotes
Expand Down Expand Up @@ -265,11 +264,7 @@ end

function Base.show(io::IO, ow::WaveGrowth2D)

if ow.ODEsystem isa ODESystem
sys_print = get_states(ow.ODEsystem)
else
sys_print = ow.ODEsystem
end
sys_print = ow.ODEsystem
print(io, "WaveGrowth2D ", "\n",
"├── grid: ", ow.grid, "\n",
"├── layers: ", ow.layers, "\n",
Expand Down
44 changes: 4 additions & 40 deletions src/Operators/core_1D.jl
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
module core_1D

using DifferentialEquations: OrdinaryDiffEq.ODEProblem, init
using ModelingToolkit: ODESystem ## depriciate when MTK is removed

using SharedArrays
#using ModelingToolkit: Num
using DocStringExtensions
# Particle-Node interaction
export GetParticleEnergyMomentum, GetVariablesAtVertex, Get_u_FromShared, ParticleDefaults
Expand Down Expand Up @@ -144,8 +142,8 @@ InitParticleInstance(model::WaveGrowth1D, z_initials, pars, ij ; cbSets=nothing
wrapper function to initalize a particle instance
inputs:
model is an initlized ODESytem
z_initials is the initial state of the ODESystem
pars are the parameters of the ODESystem
z_initials is the initial state of the Any
pars are the parameters of the Any
ij is the (i,j) tuple that of the initial position
chSet (optional) is the set of callbacks the ODE can have
"""
Expand Down Expand Up @@ -179,40 +177,6 @@ function InitParticleInstance(model, z_initials, ODE_settings, ij, boundary_flag
end


# ODESystem version, will be depriciated
"""
InitParticleInstance(model::WaveGrowth1D, z_initials, pars, ij ; cbSets=nothing)
wrapper function to initalize a particle instance
inputs:
model is an initlized ODESytem
z_initials is the initial state of the ODESystem
pars are the parameters of the ODESystem
ij is the (i,j) tuple that of the initial position
chSet (optional) is the set of callbacks the ODE can have
"""
function InitParticleInstance(model::ODESystem, z_initials, ODE_settings, ij, boundary_flag, particle_on; cbSets=Nothing)

z_initials = initParticleDefaults(z_initials)
# create ODEProblem
problem = ODEProblem(model, z_initials, (0.0, ODE_settings.total_time), ODE_settings.Parameters)
# inialize problem
# works best with abstol = 1e-4,reltol=1e-3,maxiters=1e4,
integrator = init(
problem,
ODE_settings.solver,
saveat=ODE_settings.saving_step,
abstol=ODE_settings.abstol,
adaptive=ODE_settings.adaptive,
dt=ODE_settings.dt,
dtmin=ODE_settings.dtmin,
force_dtmin=ODE_settings.force_dtmin,
maxiters=ODE_settings.maxiters,
reltol=ODE_settings.reltol,
callback=ODE_settings.callbacks,
save_everystep=ODE_settings.save_everystep)
return ParticleInstance1D(ij, z_initials[3], integrator, boundary_flag, particle_on)
end



"""
Expand Down Expand Up @@ -320,7 +284,7 @@ end

"""
SeedParticle!(ParticleCollection ::Vector{Any}, State::SharedMatrix, i::Int64,
particle_system::ODESystem, particle_defaults::Dict{Number, Float64}, ODE_defaults::Dict{Number, Float64},
particle_system::Any, particle_defaults::Dict{Number, Float64}, ODE_defaults::Dict{Number, Float64},
GridNotes, winds, DT:: Float64, Nx:: Int, boundary::Vector{Int}, periodic_boundary::Bool)
Seed Pickles to ParticleColletion and State
Expand All @@ -339,7 +303,7 @@ function SeedParticle!(
DT::Float64,

boundary::Vector{T},
periodic_boundary::Bool) where {T<:Union{Int,Any,Nothing,Int64},PP<:Union{ParticleDefaults,Nothing},SS<:Union{ODESystem,Any}}
periodic_boundary::Bool) where {T<:Union{Int,Any,Nothing,Int64},PP<:Union{ParticleDefaults,Nothing},SS<:Any}

# get x position
x = GridNotes.x[i]
Expand Down
2 changes: 1 addition & 1 deletion src/Operators/core_1D_old.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ using ParticleInCell

using DifferentialEquations
using ParticleMesh: OneDGrid, OneDGridNotes
using ModelingToolkit: ODESystem
# using ModelingToolkit: ODESystem

using FetchRelations

Expand Down
Loading

0 comments on commit 2f0c987

Please sign in to comment.