source: CIVL/examples/accuracy/diffusion.cvl@ 64f7cb1

1.23 2.0 main test-branch
Last change on this file since 64f7cb1 was d980649, checked in by Manchun Zheng <zmanchun@…>, 10 years ago

fixed extra parenthesis.

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

  • Property mode set to 100644
File size: 891 bytes
Line 
1/* Commandline execution:
2 * civl verify -inputn=4 diffusion.cvl
3 * */
4#include<civlc.cvh>
5
6$input int n = 4; /* 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.