Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CryoGrid.jl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CryoGrid
CryoGrid.jl
Commits
29c18756
Commit
29c18756
authored
3 years ago
by
Brian Groenke
Browse files
Options
Downloads
Patches
Plain Diff
Fix dispatch issues with CFL callback
parent
8274ff57
No related branches found
No related tags found
1 merge request
!36
Fix CFL step limiter callback choking on autodiff types
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
examples/heat_vgfc_seb_samoylov_custom.jl
+1
-0
1 addition, 0 deletions
examples/heat_vgfc_seb_samoylov_custom.jl
src/Callbacks/Callbacks.jl
+1
-0
1 addition, 0 deletions
src/Callbacks/Callbacks.jl
src/Callbacks/courant_step.jl
+2
-2
2 additions, 2 deletions
src/Callbacks/courant_step.jl
with
4 additions
and
2 deletions
examples/heat_vgfc_seb_samoylov_custom.jl
+
1
−
0
View file @
29c18756
...
...
@@ -50,6 +50,7 @@ p.soil.n .= 2.0
p
.
soil
.
Tₘ
.=
273.15
# K
# CryoGrid front-end for ODEProblem
prob
=
CryoGridProblem
(
model
,
tspan
,
p
)
# OPTIONAL: solve for short time period to
# solve with forward Euler (w/ CFL) and construct CryoGridOutput from solution
out
=
@time
solve
(
prob
,
Euler
(),
dt
=
2
*
60.0
,
callback
=
CFLStepLimiter
(
model
),
saveat
=
24
*
3600.0
,
progress
=
true
)
|>
CryoGridOutput
;
# Plot it!
...
...
This diff is collapsed.
Click to expand it.
src/Callbacks/Callbacks.jl
+
1
−
0
View file @
29c18756
...
...
@@ -4,6 +4,7 @@ import CryoGrid
using
CryoGrid
.
Numerics
using
CryoGrid
.
Setup
:
CryoGridSetup
,
HeatOnlySetup
,
getvar
using
CryoGrid
.
Utils
using
DiffEqCallbacks
...
...
This diff is collapsed.
Click to expand it.
src/Callbacks/courant_step.jl
+
2
−
2
View file @
29c18756
...
...
@@ -2,7 +2,7 @@ struct CFLHeatState{A}
Δt
::
A
default_dt
::
Float64
end
function
(
fn
::
CryoGridCallbackFunction
{
CFLHeatState
{
<:
AbstractArray
}})(
u
,
p
,
t
)
function
(
fn
::
CryoGridCallbackFunction
{
<:
CFLHeatState
{
<:
AbstractArray
}})(
u
,
p
,
t
)
let
Δt
=
fn
.
state
.
Δt
,
Δx
=
Δ
(
fn
.
setup
.
grid
),
Ceff
=
getvar
(
:
Ceff
,
fn
.
setup
,
u
),
# apparent heat capacity
...
...
@@ -12,7 +12,7 @@ function (fn::CryoGridCallbackFunction{CFLHeatState{<:AbstractArray}})(u,p,t)
IfElse
.
ifelse
(
isfinite
(
Δt_min
),
Δt_min
,
fn
.
default_dt
)
end
end
function
(
fn
::
CryoGridCallbackFunction
{
CFLHeatState
{
Nothing
}})(
u
,
p
,
t
)
function
(
fn
::
CryoGridCallbackFunction
{
<:
CFLHeatState
{
Nothing
}})(
u
,
p
,
t
)
let
Δx
=
Δ
(
fn
.
setup
.
grid
),
Ceff
=
getvar
(
:
Ceff
,
fn
.
setup
,
u
),
# apparent heat capacity
kc
=
getvar
(
:
kc
,
fn
.
setup
,
u
);
# thermal cond. at grid centers
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment