Skip to content

END failed to simulate some random networks #6

@Xxiao-Li

Description

@Xxiao-Li

example:

The adj of a random network:

 0  0  0  0  1  0  0  1  0  0  0  0  0  0  0
 0  0  0  0  0  0  0  0  0  1  0  0  0  0  0
 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
 1  1  0  0  1  0  0  0  1  0  0  0  0  0  0
 0  0  1  0  0  0  1  1  0  1  0  1  0  1  0
 0  1  0  0  0  0  0  0  1  0  0  0  0  0  0
 0  0  0  0  0  0  0  0  0  1  1  1  0  0  0
 0  0  0  0  1  0  0  0  1  0  1  0  0  0  0
 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
 0  1  0  0  0  0  0  0  0  0  0  0  1  1  0
 0  0  1  0  1  0  0  1  0  0  0  0  0  0  0
 0  1  0  0  0  1  0  0  0  0  1  0  0  0  0
 0  0  0  0  0  0  0  0  0  1  0  0  0  0  0
 0  0  0  0  0  0  0  0  0  0  0  0  0  0  1
 0  1  0  0  0  0  0  0  0  0  0  0  0  0  0
fw = Foodweb(adj)
params = default_model(
            fw,
            BodyMass(; Z = 100),
            ClassicResponse(; h = 2),
        )
B0 = rand(params.S) .+ 0.1

sol = simulate(
        params, B0, tmax;
        callback = CallbackSet(
            extinction_callback(params, 1e-6; verbose = false),  # extinction threshold
            TerminateSteadyState(1e-8, 1e-6, DiffEqCallbacks.allDerivPass; min_t = tmin),
        ),
        show_degenerated = false,
    )

it shows:

┌ Warning: Automatic dt set the starting dt as NaN, causing instability. Exiting.
└ @ OrdinaryDiffEqCore ~/.julia/packages/OrdinaryDiffEqCore/GMkz9/src/solve.jl:645
┌ Warning: NaN dt detected. Likely a NaN value in the state, parameters, or derivative value caused this outcome.
└ @ SciMLBase ~/.julia/packages/SciMLBase/R6qe7/src/integrator_interface.jl:618
retcode: DtNaN
Interpolation: 3rd order Hermite
t: 1-element Vector{Float64}:
 0.0
u: 1-element Vector{Vector{Float64}}:
 [0.33799431755994946, 0.9726350330830773, 0.9771703657739167, 0.9897313906566511, 0.5855513278526262, 0.720193374688015, 0.9330459139050444, 0.38000574182981206, 1.0712396001667956, 0.41164516484022906, 0.9524653571088514, 0.7202570690812273, 0.5095119945014907, 0.8785674805016142, 0.5898278369987708]

This is because species body mass:

julia> params.body_mass
15-element EcologicalNetworksDynamics.BodyMasses:
 Inf
 Inf
  1.0
 Inf
 Inf
 Inf
 Inf
 Inf
  1.0
 Inf
 Inf
 Inf
 Inf
 Inf
 Inf
julia> EcologicalNetworksDynamics.Internals.trophic_levels(params.A)
15-element Vector{Float64}:
 1.0573668690348124e16
 2.401919801264265e16
 1.0
 1.2172772905863732e16
 1.4098224920464162e16
 1.2009599006321326e16
 1.5142537877535582e16
 7.049112460232083e15
 1.0
 2.4019198012642644e16
 7.049112460232083e15
 1.4359303159732018e16
 2.401919801264265e16
 2.401919801264265e16
 2.401919801264265e16

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions