source: CIVL/examples/accuracy/diffusion.cvl@ 44a7259

1.23 2.0 main test-branch
Last change on this file since 44a7259 was 95f2d75, checked in by Tim Zirkel <zirkeltk@…>, 12 years ago

Added support for $real type. Modified accuracy examples to use it for abstract functions.

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@610 fb995dde-84ed-4084-dfe6-e5aef3e2452c

  • Property mode set to 100644
File size: 879 bytes
Line 
1/* Commandline execution:
2 * civl verify -inputn=4 diffusion.cvl
3 * */
4#include<civlc.h>
5
6$input int n; /* Number of points */
7$input double h; /* Distance between points */
8$input double dt; /* Size of a time step */
9$input double k; /* Constant for rate of diffusion */
10$input double u1[n];
11$abstract $contin(4) $real u($real x, $real t);
12$assume h > 0;
13$assume dt > 0;
14$assume k > 0;
15double v[n];
16double v_new[n];
17int iter;
18
19void update() {
20 $assume $forall {j=0 .. n-1} v[j] == u(j*h, iter*dt);
21 for (int i = 1; i < n-1; i++) {
22 v_new[i] = v[i]+dt*k*(v[i+1]-2*v[i]+v[i-1])/(h*h);
23 }
24 for (int i = 1; i < n-1; i++) {
25 v[i] = v_new[i];
26 }
27 $assert($uniform{m=1 .. n-2} (u(m*h, (iter+1)*dt)-v[m])/dt-$D[u, {t, 1}](m*h, iter*dt)+k*$D[u,{x,2}](m*h, iter*dt) ==$O(dt)+$O(h*h));
28}
29
30void main() {
31 for (int i = 0; i < n; i++) {
32 v[i] = u1[i];
33 }
34 iter = 0;
35 update();
36}
Note: See TracBrowser for help on using the repository browser.