Browse code

Тесты из статьи Фролова. Б, В и Г.

Dmitrii Kashin authored on 26/05/2015 04:49:28
Showing 3 changed files
... ...
@@ -39,7 +39,8 @@
39 39
 ;; возможно, фиксированное поле надо откуда-то задавать
40 40
 
41 41
 (defmethod fixed ((grid grid2d-pv) (index cell-index) border)
42
-  (noop))
42
+  (when (zerop (iteration grid))
43
+    (zeroe grid index border)))
43 44
 
44 45
 ;; (defmethod frolov-boundary ((grid grid2d-pv) (index cell-index) border)
45 46
 ;;   (let ((i (x-index index))
... ...
@@ -94,4 +95,7 @@
94 94
 			   :var-vector (var-vector cell))))))
95 95
 
96 96
 (defmethod fixed ((grid grid2d-cv) (index cell-index) border)
97
-  (noop))
97
+  (when (zerop (iteration grid))
98
+    (zeroe grid index border)))
99
+
100
+
... ...
@@ -11,7 +11,7 @@
11 11
     (format t "Вывод каждые ~d итераций.~%" output-every-step))
12 12
   (when output-every-time
13 13
     (format t "Вывод каждые ~a секунд.~%" output-every-time))
14
-  (unless (or finish-step finish-time)
14
+  (unless (or finish-step finish-time finish-convergence)
15 15
     (error "По крайней мере одно условие остановки должно быть указано"))
16 16
   (when finish-step
17 17
     (format t "Остановка после ~d итераций.~%" finish-step))
... ...
@@ -281,15 +281,15 @@
281 281
 
282 282
 
283 283
 
284
-(defun test-kt-frolov-b (&key (cells-nx 100) (cells-ny 1) (cu 1) (output-dir #P"~/prog/clfpv/test-kt-frolov-b/"))
284
+(defun test-kt-frolov-b (&key (cells-nx 100) (cells-ny 1) (cu 0.001) (output-dir #P"~/prog/clfpv/test-kt-frolov-b/"))
285 285
   "Тест из статьи Фролова с источниковыми членами. В статье обозначен как Б."
286 286
   (ensure-directories-exist output-dir)
287 287
   (let ((*DEFAULT-PATHNAME-DEFAULTS* output-dir))
288 288
     (let ((grid (make-instance 'grid2d-cv
289 289
 			       :cells-amount-x cells-nx
290 290
 			       :cells-amount-y cells-ny
291
-			       :left-boundary-condition 'zeroe
292
-			       :right-boundary-condition 'zeroe
291
+			       :left-boundary-condition 'fixed
292
+			       :right-boundary-condition 'fixed
293 293
 			       :bottom-boundary-condition 'zeroe
294 294
 			       :top-boundary-condition 'zeroe)))
295 295
       (gridbg "1 (instance)" grid)
... ...
@@ -326,11 +326,94 @@
326 326
       (gridbg "4 (boundaries)" grid)
327 327
       (gridbg "start-grid" grid)
328 328
       (let ((newgrid (march grid
329
-			    :finish-step 1000
330
-			    :output-every-step 50
329
+			    :finish-convergence 1.0d-6
330
+			    :output-every-time 0.0001
331
+			    :output-every-step 10
332
+			    :cu cu
333
+			    )))
334
+	(gridbg "final-grid" newgrid)
335
+	newgrid
336
+	)
337
+      )))
338
+
339
+
340
+
341
+(defun test-kt-frolov-d (&key (cells-nx 100) (cells-ny 1) (cu 0.001)
342
+			   (perturbation-coef 0.01)
343
+			   (output-dir #P"~/prog/clfpv/test-kt-frolov-d/"))
344
+  "Тест из статьи Фролова с источниковыми членами. В статье обозначен как Г."
345
+  (ensure-directories-exist output-dir)
346
+  (let ((*DEFAULT-PATHNAME-DEFAULTS* output-dir))
347
+    (let ((grid (make-instance 'grid2d-cv
348
+			       :cells-amount-x cells-nx
349
+			       :cells-amount-y cells-ny
350
+			       :left-boundary-condition 'fixed
351
+			       :right-boundary-condition 'fixed
352
+			       :bottom-boundary-condition 'zeroe
353
+			       :top-boundary-condition 'zeroe)))
354
+      (gridbg "1 (instance)" grid)
355
+      (init-grid grid
356
+		 :left-border-coord 0.0d0
357
+		 :right-border-coord 1.0d0
358
+		 :top-border-line (constant-function 1.0d0)
359
+		 :bottom-border-line (constant-function 0.0d0)
360
+		 :thickening-coef-x 1
361
+		 :thickening-coef-y 1)
362
+      (gridbg "2 (init-grid)" grid)
363
+
364
+      (let ((Pin (* 20 100000.0d0))
365
+	    (Pout (* 10 100000.0d0))
366
+	    (phi 0.01d0)
367
+	    (ug 25.0d0)
368
+	    (ul 30.0d0))
369
+	(let ((left (make-instance 'primitive-variables
370
+				   :phi phi
371
+				   :P Pin
372
+				   :ug ug
373
+				   :ul ul))
374
+	      (right (make-instance 'primitive-variables
375
+				    :phi phi
376
+				    :P Pout
377
+				    :ug ug
378
+				    :ul ul)))
379
+	  (set-monotonous-field-2d-x grid
380
+				     :left-vars left
381
+				     :right-vars right)))
382
+
383
+      ;; вносим возмущение поля
384
+      (flet ((perturbate (i)
385
+	       (1+ (* perturbation-coef
386
+		      (sin (* (+ (* 2 i) 1) 0.5d0 pi))))))
387
+	(let* ((left-index (index (min-x-index grid) 0))
388
+	       (left-cell (cell grid left-index))
389
+	       (right-index (index (max-x-index grid) 0))
390
+	       (right-cell (cell grid right-index)))
391
+	  (perturbate-field-x grid #'perturbate)
392
+	  (setf (cell grid left-index) left-cell)
393
+	  (setf (cell grid right-index) right-cell)))
394
+
395
+      (gridbg "3 (set-field)" grid)
396
+      (update-boundary-cells grid)
397
+      (gridbg "4 (boundaries)" grid)
398
+      (gridbg "start-grid" grid)
399
+      (let ((newgrid (march grid
400
+			    :finish-convergence 1.0d-6
401
+			    :output-every-time 0.0001
402
+			    :output-every-step 10
331 403
 			    :cu cu
332 404
 			    )))
333 405
 	(gridbg "final-grid" newgrid)
334 406
 	newgrid
335 407
 	)
336 408
       )))
409
+
410
+(defun test-kt-frolov-c (&key (cells-nx 100) (cells-ny 1) (cu 0.001)
411
+			   (perturbation-coef 0.1)
412
+			   (output-dir #P"~/prog/clfpv/test-kt-frolov-c/"))
413
+  "Тест из статьи Фролова с источниковыми членами. В статье обозначен как В."
414
+  (test-kt-frolov-d :cells-nx cells-nx
415
+		    :cells-ny cells-ny
416
+		    :cu cu
417
+		    :perturbation-coef perturbation-coef
418
+		    :output-dir output-dir)
419
+  )