-
Notifications
You must be signed in to change notification settings - Fork 1
/
DFMPLOTS.PAS
1430 lines (1261 loc) · 43.1 KB
/
DFMPLOTS.PAS
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
Unit DfmPlots;
{ PMS 01-December-2020 20:09:39 }
{---------------------------------------------------------------------------}
{ ************* COPYRIGHT (C) Materials Group, **************
************* Cambridge University Engineering **************
************* Department, Cambridge, UK. **************
************* P.M.Sargent and M.F.Ashby **************
************* June 1993 **************
This is free software, you can redistribute it and/or modify it
under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
The file COPYING enclosed with this software contains a copy of
version 2 of the GNU General Public License which should not be
altered in any way. If it is missing, write to the Free Software
Foundation Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
---------------------------------------------------------------------------}
{$R+} {Range checking on}
{$B+} {BOOLEAN complete evaluation on}
{$S+} {Stack checking on}
{$I+} {I/O checking on}
Interface
Uses
DfmGlbls,
DfmGraph;
PROCEDURE DETECT_SKIP;
PROCEDURE PLOT_STRAIN_RATES_BOX (LgSNfirst, LgSNlast: real);
{ ----- Constructs box for temperature DFM-map and labels the axes ----- }
PROCEDURE IDENTIFY_CONTOURS;
{ ----- Identify the time contours and add the date ----- }
PROCEDURE IDENTIFY_FIELDS;
PROCEDURE CALC_STRAIN_RATES_MAP;
VAR
st : String; { Dummy string used with Str() and OutText() }
pointcount,
temp_position,
stress_position : T_mecharray;
Rate : a_real;
Stress : a_real;
hint_stress : a_real;
shear_mod : a_real;
skip : BOOLEAN;
quit : BOOLEAN;
{===========================================================================}
Implementation
Uses
Crt,
Dos,
Printer,
Graph,
StringIO,
DfmModls;
CONST
C_num_cntrs = maxcontournumber+1;
C_num_bndrys = numberofmechanisms*2; { estimate }
TYPE
T_all_contours = ARRAY [1..maxcontournumber,0..max_steps] OF INTEGER;
T_contour_reals = ARRAY [0..maxcontournumber] OF a_real;
E_n_bndrys = 1..C_num_bndrys;
T_bndry_item = RECORD
stress_hi : a_real;
id_hi : E_mech;
stress_lo : a_real;
id_lo : E_mech;
stress_mn : a_real;
END;
T_bndry_table = ARRAY [E_n_bndrys] OF T_bndry_item;
E_n_stress = 0..C_num_cntrs;
T_field_stress = RECORD
stress : a_real;
id : E_mech;
rate : a_real;
visible : BOOLEAN;
converged: BOOLEAN;
END;
T_field_ids = ARRAY [E_n_stress] OF T_field_stress;
VAR
Ch : CHAR;
contour : T_contour_reals;
contourmark : T_contour_reals;
LgSNfirst : a_real;
LgSNlast : a_real;
LgSNstep : a_real;
Lgt_first,
Lgt_last,
Lgt_step : a_real;
sqrt_factor : a_real;
last_Rate : a_real;
LgS : a_real;
xr, yr : a_real;
code : INTEGER;
c : CHAR;
s : String;
f : Text;
x_last, x_now : INTEGER;
field_ids : T_field_ids;
n_bndrys, last_n_bndrys : E_n_bndrys;
bndry_tabl, last_bndry_tabl : T_bndry_table;
{---------------------------------------------------------------------------}
PROCEDURE DETECT_SKIP;
BEGIN
{ ----- Detect <Esc> key if pressed ----- }
IF modefast THEN
Exit; { i.e. quit this procedure }
IF Keypressed THEN
BEGIN
Ch := ReadKey;
IF Ch = Esc THEN
skip:=TRUE { skip }
ELSE IF (Ch = #0 ) THEN { function key, throw away }
Ch := Readkey
ELSE IF (Ch = ' ') THEN { pause }
BEGIN
REPEAT UNTIL Keypressed;
Ch := Readkey;
IF (Ch = #0 ) THEN { function key, throw away }
Ch := Readkey
END;
END;
END; { DETECT_SKIP }
{---------------------------------------------------------------------------}
PROCEDURE PLOT_STRAIN_RATES_BOX (LgSNfirst, LgSNlast: real);
{ ----- Constructs box for temperature DFM-map and labels the axes ----- }
var
xscale, yscale : INTEGER;
Tinterval : REAL;
xmark, ymark : INTEGER;
scale : INTEGER;
TW, TH : INTEGER;
T, Tnormalised : Real;
S, Sfirst, Slast : Real;
LgSfirst, LgSlast : Real;
minor : Byte; { The number of minor marks between big marks }
BEGIN
{ --------- Draw Box ----------}
MySetColor(white);
myLine(xoffset,yoffset,xoffset,yend);
myLine(xoffset,yoffset,xend,yoffset);
myLine(xend,yend,xoffset,yend);
myLine(xend,yend,xend,yoffset);
{ --------- Put on NORMALIZED STRESS scale --------- }
minor := 1; { because it's a log axis, so minor marks are not useful }
yscale := round(LgSNlast*minor - LgSNfirst*minor);
MySetColor(yellow);
FOR scale := (round(LgSNfirst*minor)) to (round(LgSNfirst*minor) + yscale - 1) DO
BEGIN
ymark := yoffset +
ylength - round((scale - round(LgSNfirst*minor))/yscale*ylength);
IF (frac(scale/minor) = 0) THEN
myLine(xoffset,ymark,xend,ymark)
ELSE
myLine(xoffset,ymark,xoffset+3,ymark);
END;
{ --------- Put on ABSOLUTE STRESS scale ---------- }
{ in Mpa, but shmod is in GPa so multiply by 1000 }
Sfirst := shmod*SNfirst*1.0e3; { shmod is at 300 K }
Slast := shmod*SNlast *1.0e3; { shmod is at 300 K }
LgSfirst := Ln(Sfirst)/Ln10;
LgSlast := Ln(Slast)/Ln10;
IF (Sfirst <= 1.0e-9) THEN
BEGIN
MyPlotText(xoffset+2,100,'Error, low stress limit too low!');
Str(Sfirst:4:1,st);
MyPlotText(xoffset+2,105,st);
IF NOT modefast THEN
Repeat Until Keypressed;
END;
S := 1.0e-9;
REPEAT
S := S * 10;
UNTIL (S >= Sfirst);
Str(S:4:1,st);
IF (S < Slast) THEN
MyPlotText (585,189,st);
ymark := 0;
REPEAT
IF (S > Sfirst) and (S < Slast) THEN
ymark := yoffset +
round(ylength*(1 - (Ln(S)/Ln10 - LgSfirst)/
(LgSlast - LgSfirst)));
IF (ymark >= yoffset) AND (ymark <= yend) THEN
myLine(xend,ymark,xend-6,ymark);
{ ----- Nested IFs because of BUG with 8087 chip if IFs too complicated }
Str(S:4:1,st);
IF (S >= (Slast/10)) THEN
IF (S <= Slast) THEN
MyPlotText (585,10,st);
S := S * 10;
UNTIL (S >= Slast);
{ --------- Label Normalised Stress Axes ---------- }
Str(LgSNlast:4:2,st);
MyPlotText(42,10,st);
Str(LgSNfirst:4:2,st);
MyPlotText(42,189,st);
{ --------- Put on NORMALIZED TEMPERATURE scale ---------- }
xscale := round((TNlast - TNfirst)*100);
MySetColor(yellow);
FOR scale := (round(TNfirst*100)) to (round(TNfirst*100) + xscale - 1) DO
BEGIN
xmark := xoffset +
round((scale- round(TNfirst*100))/xscale*xlength);
IF (frac(scale/20) = 0) THEN
myLine(xmark, yend,xmark,yoffset);
IF (frac(scale/10) = 0) THEN
myLine(xmark, yend,xmark,(yend - 4));
END;
{ --------- Put on the CENTIGRADE TEMPERATURE scale ---------- }
xmark := 0;
T := -400;
Tinterval := 100;
IF round((TNlast - TNfirst)*tmelt/200) > 10 THEN Tinterval := 200;
MySetColor(yellow);
repeat
T := T + Tinterval;
Tnormalised := (T + 273)/tmelt;
IF (Tnormalised > TNfirst) and (Tnormalised < TNlast) THEN
xmark := xoffset +
round((Tnormalised - TNfirst)/(TNlast - TNfirst)*xlength);
IF (xmark >= xoffset) AND (xmark <= xend) THEN
myLine(xmark,yoffset,xmark,yoffset+3);
Str(round(T):6,st);
IF (Tnormalised>=TNfirst) THEN
IF (Tnormalised<(TNfirst+(Tinterval/tmelt))) THEN
MyPlotText(80,5,st);
until (Tnormalised > TNlast);
Str(TNfirst:4:2,st);
MyPlotText(70,196,st);
Str(TNlast:4:2,st);
MyPlotText(569,196,st);
Str(round(T - Tinterval):6,st);
MyPlotText(511,5,st);
{ ----- Label horizontal and vertical axes of graph window ----- }
MyPlotText(200,196,' NORMALISED TEMPERATURE T/Tm');
MyPlotText(216,5,' TEMPERATURE (C) ');
MySetTextDir(Graph.VertDir);
MyPlotText(56,100,'NORM SHEARSTRESS');
MyPlotText(599,100,'STRESS (MPa) ');
MySetTextDir(Graph.HorizDir);
END; {PLOT_STRAIN_RATES_BOX. }
{---------------------------------------------------------------------------}
PROCEDURE PLOT_STRAIN_RATES_INFO;
{ ----- Information box in top-right corner ----- }
BEGIN
DATE_AND_TIME;
MySetColor(white);
{ these calls to myLine use actual pixels in the viewport}
myLine(xoffset+round(3*xlength/4),yoffset+round(ylength/4),
xoffset+xlength,yoffset+round(ylength/4));
myLine(xoffset+round(3*xlength/4),yoffset+round(ylength/4),
xoffset+round(3*xlength/4),yoffset);
{ these calls to ClearTextSpace and MyPlotText use 'notional 640x200 scaled pixels'}
ClearTextSpace(456,12,630,55, False);
MyPlotText(465,16,matlname);
IF (Gsize*1.0e6 < 0.1) THEN { less than 0.1 microns, do in nm }
BEGIN
Str((Gsize*1.0e9):4:1,st);
MyPlotText(465,24,'d = '+st+' nm');
END
ELSE
BEGIN
Str((Gsize*1.0e6):4:1,st);
MyPlotText(465,24,'d = '+st+' um');
END;
MyPlotText(465,48,date_string);
END; { PLOT_STRAIN_RATES_INFO }
{---------------------------------------------------------------------------}
PROCEDURE DRAW_FIELD_BOUNDARY (x,y : INTEGER);
{ the vertical lines at a specific temperature on the map showing limits to some mechanisms }
CONST
s1 = 2;
s2 = 1;
BEGIN
{ This is called within the Stress-Loop, within the Temperature-Loop,
so the plotting window is already set to the graph axes }
MySetColor(blue);
myLine(x-s1, y, x+s1,y);
myLine(x-s1, y+s2, x+s1,y+s2);
MySetColor(white);
END; {DRAW_FIELD_BOUNDARY. }
{---------------------------------------------------------------------------}
PROCEDURE DRAW_FIELD_LINE(i, j: E_n_stress);
{ the boundaries between mechanisms on the map }
VAR
y_last, y_now : INTEGER;
BEGIN
{ This is called within the Stress-Loop, within the Temperature-Loop,
so the plotting window is already set to the graph axes }
WITH bndry_tabl[i] DO
y_now := round(ylength*(1 - (stress_mn - LgSNfirst)/(LgSNlast - LgSNfirst)));
WITH last_bndry_tabl[j] DO
y_last := round(ylength*(1 - (stress_mn - LgSNfirst)/(LgSNlast - LgSNfirst)));
SetLineStyle(DashedLn,0,ThickWidth);
myLine(x_last, y_last, x_now, y_now);
SetLineStyle(SolidLn,0,NormWidth);
END; {DRAW_FIELD_LINE }
{---------------------------------------------------------------------------}
PROCEDURE IDENTIFY_CONTOURS;
{ ----- Identify the time contours and add the date ----- }
BEGIN
Flush(db);
ClearTextSpace(96,159,257,183, True);
MyPlotText(96,165,' CONTOURS ');
IF ((contour[1] < 99999 ) AND ( contour[1] >= 1 )) THEN
Str(contour[1]:7:0,st)
ELSE
Str(contour[1]:7,st);
convert_number (contour[1], st, -1);
MyPlotText(96,170,' First = '+st+' /s ');
IF ((contour[contournumber] < 99999 ) AND ( contour[contournumber] >= 1 )) THEN
Str(contour[contournumber]:7:0,st)
ELSE
Str(contour[contournumber]:7,st);
convert_number (contour[contournumber], st, -1);
MyPlotText(96,178,' Last = '+st+' /s ');
END; {IDENTIFY_CONTOURS. }
{---------------------------------------------------------------------------}
PROCEDURE IDENTIFY_FIELDS;
VAR
P1,P2 : INTEGER;
r1,r2 : a_real;
x1,y1,x2,y2 : a_real;
x_shift : a_real;
y_shift : a_real;
crit : INTEGER;
x0,y0 : INTEGER;
xx1,xx2,yy1,yy2 : SMALLINT;
mech : E_mech;
BEGIN
{ ----- RE FACTOR THIS BIT - uses 80x25 character coordinates for the window! ----- }
{ This procedure had the implicit assumption that there were 80
lines to the screen, even though it was general with respect to
the number of graphics pixels on the screen.
}
{ ----- Position and print the remaining field labels ----- }
MySetColor(BROWN);
writeln(db,'IDENTIFY_FIELDS');
crit := round(steps*steps/100);
writeln(db,'report the field only if we have more points than this: ', crit);
FOR mech := null TO rel_drag DO
IF (pointcount[mech] > crit) and (pointcount[mech] > 4) THEN
BEGIN
writeln(db,'pointcount[',mechId[mech],']',pointcount[mech]:5:0);
st := mechLabel[mech];
{ ----- RE FACTOR THIS BIT - uses 80x25 character coordinates for the window! ----- }
writeln(db,st,' ',temp_position[mech]:5:0,stress_position[mech]:5:0,pointcount[mech]:5:0);
{ ----- Don't check for validity here in character co-ords, but in
graphics co-ords after conversion. PMS 4-February-1988 10:50 }
r1 := ((temp_position[mech]/steps)/pointcount[mech]*64) + 7;
r2 := (1 - stress_position[mech]/(pointcount[mech]*steps))*22 + 2;
{ ----- RE FACTOR THIS BIT - uses 80x25 character coordinates for the window! ----- }
x1:=(r1-1)*xVGA/80;
y1:=(r2-0.7)*yVGA/25;
x2:=(r1+Length(st)+0.2)*xVGA/80;
y2:=(r2+0.5)*yVGA/25;
{ ----- RE FACTOR THIS BIT - uses 80x25 character coordinates for the window! ----- }
x_shift := 0.0;
IF (x1 < xoffset ) THEN
x_shift := xoffset - x1 + 1.6;
IF (x2 > xend ) THEN
x_shift := xend - x2 + 1.6;
{ ----- RE FACTOR THIS BIT - uses 80x25 character coordinates for the window! ----- }
y_shift := 0.0;
IF (y1 < yoffset ) THEN
y_shift := yoffset - y1 + 4;
IF (y2 > yend ) THEN
y_shift := yend - y2 + 4;
{ ----- RE FACTOR THIS BIT - uses 80x25 character coordinates for the window! ----- }
xx1 := round(x1+x_shift);
xx2 := round(x2+x_shift);
yy1 := round(y1+y_shift);
yy2 := round(y2+y_shift);
ClearTextSpace(xx1,yy1, xx2,yy2, True);
x0:=Round(r1*xVGA/80 + x_shift);
y0:=Round(r2*yVGA/25 + y_shift);
MyPlotText(x0, y0, st);
{ ----- RE FACTOR THIS BIT - uses 80x25 character coordinates for the window! ----- }
END
ELSE
writeln(db,st,' not shown as too small',pointcount[mech]:5:0);
Flush(db);
END; {IDENTIFY_FIELDS. }
{---------------------------------------------------------------------------}
PROCEDURE Contours_Init;
VAR
c : E_n_stress;
BEGIN
FOR c := 0 TO C_num_cntrs DO
BEGIN
field_ids[c].stress := -1.0;
field_ids[c].id := null;
field_ids[c].rate := 1.0e-20;
field_ids[c].visible:= FALSE;
field_ids[c].converged:= FALSE;
END;
END; { Contours_Init procedure }
{---------------------------------------------------------------------------}
{$IFDEF cntrfix }
{$I \dfmap\old_cntr.pas }
{$ELSE}
PROCEDURE Contours_Loop (temp_step: Word);
VAR
field : E_mech;
c,cc,
n_actual : E_n_stress;
root_factor : a_real;
Rate : a_real;
LgSN : a_real;
LgRatio : a_real;
hint_stress : a_real;
mark_step : a_real;
min_rate_on_plot : a_real;
max_rate_on_plot : a_real;
prev_stress,
prev_rate : a_real;
{------------------------------------------------------------------------}
PROCEDURE Contours_debug;
VAR
c : E_n_stress;
BEGIN
Writeln(db,'[c] LgCntr C''mark stress rate visible field');
FOR c := n_actual DOWNTO 0 DO
WITH field_ids[c] DO
BEGIN { For loop & With block }
IF (c>=n_actual) OR (c<=0) THEN
Write(db, c:3,' --limit-- ',stress:8:3,' ')
ELSE
Write(db, c:3,' ',(Ln(contour[c])/Ln10):8:1,
' ',contourmark[c]:9:5,
' ',stress:8:3,' ');
Write(db, rate:12,' ');
IF visible THEN
Write(db,' Visible ')
ELSE
Write(db,'Invisible ');
WRITE_FIELDNAME(id);
IF converged THEN
Write(db,' ')
ELSE
Write(db,' *');
WriteLn(db);
END; { For loop & With block }
WriteLn(db);
END; { Contours_debug }
{------------------------------------------------------------------------}
PROCEDURE Iterate_One_Contour(previous_stress, previous_rate, LgSN: a_real;
c: E_n_stress);
CONST
iter_limit = 13;
VAR
RateRatio, SNdiff, strain_rate : a_real;
step, factor : a_real;
n : Byte;
{---------------------------------------------------------------------}
PROCEDURE Bisect;
VAR
Rate_ratio : a_real;
BEGIN
LgSN := (LgSN + previous_stress)/2.0;
SNdiff := LgSN - previous_stress;
{ Another (better) estimate, if everything is NOT weird }
IF ((previous_rate > contour[1])
AND (previous_rate < contour[contournumber]))
AND ((strain_rate > contour[1])
AND (strain_rate < contour[contournumber])) THEN
BEGIN
Rate_ratio := (contour[c] - previous_rate)/(strain_rate - previous_rate);
LgSN := previous_stress + (LgSN - previous_stress)*Rate_ratio;
{$IFDEF contour}
Write(db,' !!');
{$ENDIF}
END;
SNdiff := LgSN - previous_stress;
END; { Bisect }
{---------------------------------------------------------------------}
BEGIN { Iterate_One_Contour }
{$IFDEF contour}
WriteLn(db);
{$ENDIF}
step := 1.0;
n := 0;
SNdiff := LgSN - previous_stress;
REPEAT
STRAIN_RATES (TN, LgSN, strain_rate, field, hint_stress);
RateRatio := (strain_rate/contour[c]);
IF (RateRatio < 1) THEN
RateRatio := 1/RateRatio;
Inc(n);
Flush(db);
{$IFDEF contour}
WriteLn(db);
WriteLn(db,
' c =',c:2,
' Rates: ',previous_rate:12,'->',field_ids[c].rate:12,' ->',strain_rate:12,
' LgSN : ',previous_stress:8:3,'->',field_ids[c].stress:8:3,' ->',LgSN:8:3);
Write(db,
' SNdiff =',SNdiff:8:3,
' factor =',factor:8:3,
' (rate/contour)=',(strain_rate/contour[c]):12,
' inv.=',RateRatio:12);
{$ENDIF}
field_ids[c].id := field; { and update.. }
IF ((contour[c] > strain_rate) AND (contour[c] < previous_rate))
OR ((contour[c] < strain_rate) AND (contour[c] > previous_rate)) THEN
BEGIN
{ Throw away the field_ids[c].stress, keep previous (& current) }
field_ids[c].rate := strain_rate;
field_ids[c].stress := LgSN;
Bisect;
{$IFDEF contour}
WriteLn(db,' BISECT- ');
{$ENDIF}
END
ELSE
IF ((contour[c] > strain_rate) AND (contour[c] < field_ids[c].rate))
OR ((contour[c] < strain_rate) AND (contour[c] > field_ids[c].rate)) THEN
BEGIN
{ Throw away the previous_stress, keep field_ids[c].stress (& current) }
previous_rate := field_ids[c].rate;
previous_stress := field_ids[c].stress;
field_ids[c].rate := strain_rate;
field_ids[c].stress := LgSN;
{ previous is now 'really' field_ids[c].stress }
Bisect;
{$IFDEF contour}
WriteLn(db,' BISECT+ ');
{$ENDIF}
END
{ Split to the limits of the plot (if the contour is going to appear on
the plot, biasing heavily towards the current value of stress. }
ELSE
BEGIN { ========== extrapolation options ========== }
{ 'previous' values are not relevant or interesting here }
previous_rate := field_ids[c].rate;
field_ids[c].rate := strain_rate;
previous_stress := field_ids[c].stress;
field_ids[c].stress := LgSN;
IF ((strain_rate > contour[c]) AND (contour[c] > field_ids[0].rate)) THEN
BEGIN
LgSN := (5 * field_ids[c].stress + field_ids[0].stress)/6.0;
{$IFDEF contour}
WriteLn(db,' DROP ');
{$ENDIF}
END
ELSE IF ((strain_rate < contour[c]) AND (contour[c] < field_ids[n_actual].rate)) THEN
BEGIN
LgSN := (5 * field_ids[c].stress + field_ids[n_actual].stress)/6.0;
{$IFDEF contour}
WriteLn(db,' PUSH UP ');
{$ENDIF}
END
ELSE { catchall - very slow }
BEGIN
factor := 1.0 + step;
step := step/1.3;
IF (strain_rate > contour[c]) THEN
LgSN := field_ids[c].stress * factor { since it is -ve }
ELSE
LgSN := field_ids[c].stress / factor; { since it is -ve }
{$IFDEF detail}
WriteLn(db,' FACTOR ');
{$ENDIF}
END;
SNdiff := LgSN - field_ids[c].stress;
END; { ========== extrapolation options ========== }
UNTIL
{ ((Abs(SNdiff) < 0.5*mark_step)
AND (RateRatio < root_factor)) }
(RateRatio < root_factor)
OR (n >= iter_limit);
{ Convergence when we are closer in strain rate than any other
contour (for low temperatures), or closer in stress than the
'step length' on the map (high temperatures).
Note that we have to be quite careful that the values of .stress
and .rate in field_ids[c] are the ones that the loop actually
converged on, and not the values set up for the 'next' iteration.
30-April-1990 23:34 PMS
}
IF (n >= iter_limit) THEN { exit this loop }
BEGIN
field_ids[c].converged := FALSE;
{$IFDEF contour}
Writeln(db,' EXIT LOOP');
{$ENDIF}
END
ELSE
field_ids[c].converged := TRUE;
END; { Iterate_One_Contour }
{------------------------------------------------------------------------}
PROCEDURE Iterate_All_Contours;
{ This procedure assumes that field_ids contains some kind of estimate
of the stress and strain rate, but a very poor one. The main routine
Contours_Loop assumes that we have a very good estimate.
PMS 27-April-1990 00:45 }
VAR
c : E_n_stress;
previous_stress, previous_rate : a_real;
BEGIN
{$IFDEF contour}
Writeln(db,'Stress incr.target:',{0.5*}mark_step:8:3,
' RateRatio target: ',root_factor:8:3);
Writeln(db);
{$ENDIF}
FOR c := contournumber DOWNTO 1 DO
BEGIN
{ start them off at a self-consistent point, either the top limit
or the previous (solved) contour }
previous_stress := field_ids[c+1].stress;
previous_rate := field_ids[c+1].rate;
LgSn := previous_stress * 1.01 ; { guess, larger -ve so lower stress }
Iterate_One_Contour(previous_stress, previous_rate, LgSN, c);
END;
END; { Iterate_All_Contours }
{------------------------------------------------------------------------}
PROCEDURE Finish_Contours;
VAR
c : E_n_stress;
BEGIN
Writeln(db,'Finish_Contours called.');
FOR c := contournumber DOWNTO 1 DO
Writeln(db,'contournumber: ',c);
Writeln(db,'contournumber: ',c, 'fields_id: ',field_ids[c].id);
contourmark[c] := (field_ids[c].stress - LgSNfirst)/(LgSNlast - LgSNfirst);
{$IFDEF detail}
Writeln(db,'Final values for this call to Contours_Loop');
Contours_debug;
{$ENDIF}
Writeln(db,'Finish_Contours ended.');
END; { Finish_Contours }
{------------------------------------------------------------------------}
BEGIN { Procedure Contours_Loop }
n_actual := contournumber + 1;
root_factor := sqrt(cntrfactor);
mark_step := LgSNstep/(LgSNlast - LgSNfirst);
STRAIN_RATES (TN, LgSNlast, Rate, field, hint_stress);
field_ids[n_actual].stress := LgSNlast;
field_ids[n_actual].id := field;
field_ids[n_actual].rate := Rate;
max_rate_on_plot := Rate;
Writeln(db);
STRAIN_RATES (TN, LgSNfirst, Rate, field, hint_stress);
field_ids[0].stress := LgSNfirst;
field_ids[0].id := field;
field_ids[0].rate := Rate;
min_rate_on_plot := Rate;
Writeln(db);
{$IFDEF contour}
Writeln(db);
Writeln(db,'Values with LIMITS overwritten');
Contours_debug;
{$ENDIF}
IF (TN <= 0.0) THEN { at 0 K }
BEGIN
STRAIN_RATES (TN, (LgSNfirst+LgSNlast)/2, Rate, field, hint_stress);
Writeln(db);
Writeln(db,' <- 0 K HINT CALC');
Writeln(db,'TN=',TN:8:3,' (0 K) hint stress is',hint_stress:8:3);
FOR c := 1 TO contournumber DO
BEGIN
field_ids[c].stress := hint_stress; { Obst or Peierls stress }
field_ids[c].id := field;
field_ids[c].rate := contour[c];
field_ids[c].visible:= TRUE;
END;
{ field_ids[n_actual].rate := field_ids[n_actual-1].rate; }
Finish_Contours;
Exit; { *** return from Contours_Loop here *** }
END;
IF (TN > 0.0)
AND (temp_step < 1) THEN { No previous calcs., but not at 0 K }
BEGIN
LgSN := (LgSNfirst+LgSNlast)/2;
STRAIN_RATES (TN, LgSN, Rate, field, hint_stress);
{$IFDEF detail}
Writeln(db,' <- HINT ');
{$ENDIF}
{ FOR c := 0 TO n_actual DO }
FOR c := 1 TO contournumber DO
BEGIN
field_ids[c].stress := LgSN;
field_ids[c].id := field;
field_ids[c].rate := Rate;
field_ids[c].visible:= TRUE;
END;
Iterate_All_Contours;
Finish_Contours;
Exit; { *** return from Contours_Loop here *** }
END
ELSE IF (temp_step = 1)
AND (TNfirst <= 0.0) THEN { previous step was at 0 K }
BEGIN
Iterate_All_Contours;
Finish_Contours;
Exit; { *** return from Contours_Loop here *** }
END;
{%%%%%%%%%%%%%%%%%%%%%%%%%%%finish%%%%%%%%%%%%%%%%%%%%}
{ IF (temp_step >= 15) THEN Halt(1); }
{ ========== S T A R T == T H E == S E T U P == L O O P ========= }
{ Do a first pass, using the LgSN values for the PREVIOUS temperature,
first, check which contours were visible at the PREVIOUS temperature. }
{ Only bother if we are not on the first temp. which is temp_step = 0 }
IF (temp_step >= 1) THEN
FOR c := 1 TO contournumber DO
BEGIN
{ This assumes that the last temp. got consistent stresses & strain_rates }
IF (field_ids[c].stress <= LgSNlast)
AND (field_ids[c].stress >= LgSNfirst) THEN
field_ids[c].visible := TRUE
ELSE
field_ids[c].visible := FALSE;
LgSN := field_ids[c].stress; { previous value }
STRAIN_RATES (TN, LgSN, Rate, field, hint_stress);
field_ids[c].id := field; { and update.. }
field_ids[c].rate := Rate;
END;
{ Set id for those that dropped off the bottom }
FOR c := contournumber DOWNTO 1 DO
BEGIN
IF NOT field_ids[c].visible THEN
field_ids[c].id := field_ids[c+1].id; { OK, n_actual preset }
END;
{ Set id for those that popped off the top }
FOR c := 1 TO contournumber DO
BEGIN
IF NOT field_ids[c].visible THEN
field_ids[c].id := field_ids[c-1].id; { OK, 0 is preset }
END;
{ ========== E N D == T H E == S E T U P == L O O P ========= }
{$IFDEF contour}
Writeln(db);
Writeln(db,'Values after the SETUP loop');
Contours_debug;
{$ENDIF}
{ ========== S T A R T == T H E == C O N T O U R == L O O P ========= }
{ Find stress which gives Rate closest to the required contour }
FOR c := 1 TO contournumber DO
IF field_ids[c].visible THEN
BEGIN
cc := n_actual;
REPEAT
Dec(cc);
{$IFDEF contour}
Writeln(db,'c:cc Loop',c:3,cc:3,' ',contour[c]:12,' ',field_ids[cc].rate:12);
{$ENDIF}
UNTIL (contour[c] >= field_ids[cc].rate) OR (cc = 0);
IF (contour[c] <= field_ids[0].rate) THEN
{ contour is off the bottom.. }
BEGIN
field_ids[c].id := field_ids[0].id; { and update.. }
field_ids[c].rate := field_ids[0].rate;
field_ids[c].stress := field_ids[0].stress;
{$IFDEF contour}
Writeln(db,' Contour ',c:2,' under the bottom, OK ');
{$ENDIF}
END
ELSE IF (contour[c] >= field_ids[n_actual].rate) THEN
{ contour is off the top.. }
BEGIN
field_ids[c].id := field_ids[n_actual].id; { and update.. }
field_ids[c].rate := field_ids[n_actual].rate;
field_ids[c].stress := field_ids[n_actual].stress;
{$IFDEF contour}
Writeln(db,' Contour ',c:2,' off the top, OK ');
{$ENDIF}
END
ELSE IF (contour[c] = field_ids[cc].rate) THEN
{ easy, but have to check for it explicitly }
BEGIN
field_ids[c].id := field_ids[cc].id; { and update.. }
field_ids[c].rate := field_ids[cc].rate;
field_ids[c].stress := field_ids[cc].stress;
{$IFDEF contour}
Writeln(db,' Contour ',c:2,' exact ! OK ');
{$ENDIF}
END
ELSE IF (contour[c] > field_ids[cc].rate) THEN
{ Now interpolate }
BEGIN
prev_rate := field_ids[cc].rate;
prev_stress := field_ids[cc].stress;
LgRatio := (contour[c] - prev_rate)/(field_ids[cc+1].rate - prev_rate);
LgSN := prev_stress + (field_ids[cc+1].stress - prev_stress)*LgRatio;
Iterate_One_Contour(prev_stress, prev_rate, LgSN, c);
END
ELSE
BEGIN
Writeln(db,' Should never get here ! In DfmPlots.Contour_Loops');
END;
contourmark[c] := (field_ids[c].stress - LgSNfirst)/(LgSNlast - LgSNfirst);
END; { For c loop }
{ It converges EACH contour individually before going on to the next.
This is inefficient, it should do one pass over all contours, then
continue passing and updating until all are converged since it uses
adjacent contours to get an estimate. }
{ ========== E N D == T H E == C O N T O U R == L O O P ========= }
{$IFDEF detail}
Writeln(db,'Final values for this call to Contours_Loop');
Contours_debug;
{$ENDIF}
END; { Contours_Loop procedure }
{$ENDIF} { end of IFDEF cntrfix section }
{---------------------------------------------------------------------------}
PROCEDURE Fields_Loop (temp_step: Word);
VAR
field,
field_now,
field_last,
next_down_now,
next_up_now : E_mech;
n_actual : E_n_stress;
centroid : T_mecharray;
spread : T_mecharray;
Rate : a_real;
LgSN : a_real;
hint_stress : a_real;
weight : a_real;
top, bot : a_real;
re_do : BOOLEAN;
boundaries_exist : BOOLEAN;
x_half, y_half, y_now: INTEGER;
c, i, j : E_n_stress;
k : E_n_bndrys;
s : Word; { stress_step }
{------------------------------------------------------------------------}
PROCEDURE Find_Boundaries;
VAR
i, j, item : E_n_stress;
BEGIN
{ ----- Find the Field boundaries more accurately ----- }
{ Note the trouble we go to in order to keep the table sorted,
so that we don't have to sort it later. 22-March-1990 }
i := 0;
REPEAT
IF (i+1 > C_num_cntrs) THEN
Show_Msg('Too many boundaries found on first pass')
ELSE
Inc(i);
re_do := FALSE;
WITH bndry_tabl[i] DO
BEGIN
IF ((Abs(stress_hi - stress_lo)/LgSNstep) > 0.5) THEN
BEGIN
re_do := TRUE;
LgSN := stress_mn;
{$IFDEF detail}
Writeln(db);
{$ENDIF}
STRAIN_RATES (TN, LgSN, Rate, field, hint_stress);
IF (field =id_hi) THEN
stress_hi := LgSN
ELSE IF(field =id_lo) THEN
stress_lo := LgSN;
IF (field <> id_hi)
AND (field <> id_lo) THEN
BEGIN { a new field in the middle ! }
IF (n_bndrys+1 > C_num_bndrys) THEN
Show_Msg('Too many boundaries found on interpolation')
ELSE
Inc(n_bndrys); { make array bigger }
FOR item := n_bndrys DOWNTO i+1 DO
BEGIN { Budge up.. happens infrequently }
bndry_tabl[item].stress_lo := bndry_tabl[item-1].stress_lo;
bndry_tabl[item].id_lo := bndry_tabl[item-1].id_lo;
bndry_tabl[item].stress_hi := bndry_tabl[item-1].stress_hi;
bndry_tabl[item].id_hi := bndry_tabl[item-1].id_hi;
bndry_tabl[item].stress_mn := bndry_tabl[item-1].stress_mn;
END;
{ ..and now overwrite i+1 }
bndry_tabl[i+1].stress_lo := LgSN;
bndry_tabl[i+1].id_lo := field;
bndry_tabl[i+1].stress_hi := stress_hi;
bndry_tabl[i+1].id_hi := id_hi;
bndry_tabl[i+1].stress_mn := (stress_hi + LgSN)/2.0;
{ ..and overwrite i }
stress_hi := LgSN;
id_hi := field;
END;
stress_mn := (stress_hi + stress_lo)/2.0;
END;
END; { With block }
IF re_do THEN Dec(i); { re-do the last one.. }
UNTIL ( i >= n_bndrys ); { INCLUDING the new ones.. }