1.23
2.0
main
test-branch
|
Last change
on this file since b784507 was 3ff27cf, checked in by Manchun Zheng <zmanchun@…>, 11 years ago |
|
updated examples since $assert/$assume has been changed to functions; fixed the model builder for the new side-effect remover.
git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@2085 fb995dde-84ed-4084-dfe6-e5aef3e2452c
|
-
Property mode
set to
100644
|
|
File size:
893 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);
|
|---|
| 15 | double v[n];
|
|---|
| 16 | double v_new[n];
|
|---|
| 17 | int iter;
|
|---|
| 18 |
|
|---|
| 19 | void 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 |
|
|---|
| 30 | void 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.