Skip to content

Commit

Permalink
#3312 test inf
Browse files Browse the repository at this point in the history
  • Loading branch information
hqnghi88 committed Mar 10, 2022
1 parent 492cf3b commit 9a7c8ea
Showing 1 changed file with 43 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,66 +5,77 @@
* Note: an integration step of 0.1 is considered as not precise enough. It is used here to highlight clearly the impact of the integration method.
* Tags: equation, math
***/

model LVInfluenceoftheIntegrationstep

global {

init {
create LVRK4 with: [x::2.0,y::2.0];
create LVEuler with: [x::2.0,y::2.0];
create LVRK4 with: [x::2.0, y::2.0];
create LVEuler with: [x::2.0, y::2.0];
}

}

species LVRK4 {
float t;
float x ;
float y ;
float x;
float y;
float h <- 0.1;
float alpha <- 0.8 ;
float beta <- 0.3 ;
float gamma <- 0.2 ;
float alpha <- 0.8;
float beta <- 0.3;
float gamma <- 0.2;
float delta <- 0.85;
equation eqLV {
diff(x,t) = x * (alpha - beta * y);
diff(y,t) = - y * (delta - gamma * x);
}

equation eqLV {
diff(x, t) = x * (alpha - beta * y);
diff(y, t) = -y * (delta - gamma * x);
}

reflex solving {
solve eqLV method: #rk4 step_size: h;
}

}

species LVEuler {
float t;
float x ;
float y ;
float x;
float y;
float h <- 0.1;
float alpha <- 0.8 ;
float beta <- 0.3 ;
float gamma <- 0.2 ;
float alpha <- 0.8;
float beta <- 0.3;
float gamma <- 0.2;
float delta <- 0.85;
equation eqLV {
diff(x,t) = x * (alpha - beta * y);
diff(y,t) = - y * (delta - gamma * x);
}

equation eqLV {
diff(x, t) = x * (alpha - beta * y);
diff(y, t) = -y * (delta - gamma * x);
}

reflex solving {
//int a <- #Euler;
solve eqLV method: #Euler step_size: h;
try{
solve eqLV method: #Euler step_size: h;
if(!is_finite(x)){
ask world{do pause;}
}
}

}

}

experiment examples type: gui {
output {
display LV {
output {
display LV synchronized:false {
chart 'Comparison Euler - RK4 (RK4 is more precise)' type: series background: #lightgray {
data "xRK4" value: first(LVRK4).x color: #yellow;
data "yRK4" value: first(LVRK4).y color: #blue;
data "xEuler" value: last(LVEuler).x color: #red;
data "yEuler" value: last(LVEuler).y color: #green;
}
}
data "yEuler" value: last(LVEuler).y color: #green;
}

}

}

}

0 comments on commit 9a7c8ea

Please sign in to comment.