-
Notifications
You must be signed in to change notification settings - Fork 5
/
dsmc.f
2224 lines (2188 loc) · 70.8 KB
/
dsmc.f
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
* DSMC1.FOR
*Original by G.A. Bird
*schuberm added law-kelton, maxwell & cll kernels, fixed missing particles bug
*Warning from schuberm: Check that energy is conserved
PROGRAM DSMC1
*
*--general one-dimensional steady flow program
*----includes options for cylindrical and spherical flows
*----flow gradients occur only in the direction of the x axis
*----the x axis becomes the radius in cylindrical and spherical cases
*------the origin is then at x=0
*----the axis of a cylindrical flow is along the z axis
*----in plane flows, there may be a velocity in the y direction
*----in cylindrical flow, there may be a circumferential velocity
*----the is an `inner' (smaller x) and `outer' (larger x) boundary
*----each boundary is one of five types
*-----1: an axis or centre (it must then be at x=0)
*-----2: a plane of symmetry or a specularly reflecting surface
*-----3: a solid surface
*-----4: a stream boundary
*-----5: a vacuum
*----the cell widths may be either uniform or in geometric progression
*----there may be a constant `gravitational' acceleration in plane flows
*------with type 4 or type 5 boundaries
*
*--SI units are used throughout
*
*-------------------------DESCRIPTION OF DATA---------------------------
*
*--the following is set in the PARAMETER statement
*--MNC the number of cells
*--(the other PARAMETER variables must be consistent with the data in
*----SUBROUTINE DATA1, and MNSC can set a default if NSC is not set)
*
*--IFC set to 0 or 1 for uniform or non-uniform cell widths
*---if IFC=1, set CWR as the ratio of the cell width at the outer
*----boundary to that at the inner boundary (default 0)
*
*--IFX set to 0, 1, or 2 for plane, cylindrical, or spherical flow
*
*--IIS 0 if the initial state is a vacuum, 1 if it is a uniform stream,
*----or 2 for a uniform gradient between two surfaces
*
*--FTMP the stream temperature if IIS=1, or a temperature characteristic
*----of the flow otherwise (of FTMP is not set for IIS= 0 or 2, the
*----default value of 273 is used to set the initial value of CCG(1
*
*--FND the initial number density for IIS=1, the mean value for IIS=2,
*----or need not be set for IIS=0
*
*--FSP(L) the fraction (by number) of species L in the initial stream
*----a value is requred for each species, but need not be set for IIS=0
*
*--FNUM the number of real mols. represented by each simulated molecule
*
*--DTM the time step over which the motion and collisions are uncoupled
*
*--NSC the number of sub-cells per cell (MNSC must be at least MNC*NSC)
*----this is optional because MNSC/MNC will be set as the default value
*
*--the following data is required for each boundary
*----K=1 for the inner boundary (lower value of x)
*----K=2 for the outer boundary (higher value of x)
*
*--XB(K) the x coordinate of the boundary (must be positive if IFX>1)
*
*--IB(K) the type code of the boundary
*
*--no further data on the boundary is required if:-
*----IB(K)=1 for an axis or centre (valid for IFX= 1 or 2, and XB(K)=0),
*----IB(K)=2 for a plane of symmetry (if IFX=1) or a specularly
*------reflecting surface (valid for all IFX values)
*----IB(K)=5 for an interface with a vacuum
*
*--if IB(K)=3 (a solid surface) the following are required:-
*--BT(K) the temperature of the surface (diffuse reflection)
*--BVY(K) the velocity in the y direction (not valid for IFX=2)
*
*--if IB(K)=4 (an interface with an external stream) the reqd. data is:-
*--BFND(K) the number density of the stream
*--BFTMP(K) the temperature
*--BVFX(K) the x (and only) component of the stream velocity
*--BFSP(K,L) the number fraction of species L in the stream
*----a value of BFSP is required for each species
*
*--end of the boundary data
*
*--ISPD (required only for gas mixtures) set to 0 if the diameter,
*----viscosity exponent, and VSS scattering parameter for the
*----cross-collisions are to be set to the mean values, or
*----set to 1 if these quantities are to be set as data
*
*--the following data must be repeated for each species (L=1 to MNSP)
*
*--SP(1,L) the reference diameter
*--SP(2,L) the reference temperature
*--SP(3,L) the viscosity temperature power law
*--SP(4,L) the reciprocal of the VSS scattering parameter (1. for VHS)
*--SP(5,L) the molecular mass
*
*--ISP(L) the collision sampling group in which the species lies
*----this must be LE.MNSC (not required if MNSG=1)
*
*--ISPR(1,L) the number of rotational degrees of freedom
*--ISPR(2,L) 0, 1 for constant, polynomial rotational relaxation number
*--ISPR(3,L) 0, 1 for common or collision partner species dependent
*----rotational relaxation rate
*
*--SPR(1,L,K) the constant value, or constant in the polynomial for Zr
*----in a collision of species L with species K
*--the following two items are required only if ISPR(2,L)=1
*--SPR(2,L,K) the coefficient of temperature in the polynomial
*--SPR(3,L,K) the coefficient of temperature squared in the polynomial
*
*--end of data for the individual species
*
*--the following data on the cross-collisions is required only if ISPD=1
*--then only for L.NE.M, but L,M data must be repeated for M,L
*
*--SPM(1,L,M) the reference diameter for species L-M collisions
*--SPM(2,L,M) the reference temperature for species L-M collisions
*--SPM(3,L,M) the viscosity temperature power law for species L-M colls.
*--SPM(4,L,M) the reciprocal of the VSS scattering parameter
*
*--end of species data
*
*--GRAV the gravitational acceleration in the x direction (default 0.)
*----this should be non-zero only when IFX=0 (plane flows) and the
*------boundaries are either type 4 or type 5
*
*--NIS the number of DTM time steps between samplings
*
*--NSP the number of samples between prints
*
*--NPS the number of prints to the assumed start of steady flow
*
*--NPT the number of prints to STOP
*
*-----------------------------------------------------------------------
*
PARAMETER (MNM=600000,MNC=2000,MNSC=40000,MNSP=1,MNSG=1)
*
*--variables as defined in DSMC0.FOR
*
DOUBLE PRECISION COL(MNSP,MNSP),MOVT,NCOL,SELT,SEPT,CS(7,MNC,MNSP)
*
*--variables as defined in DSMC0.FOR
*
DOUBLE PRECISION CSR(MNC,MNSP)
*
*--CSR(M,L) the sum of the rotational energy of species L in cell M
*
DOUBLE PRECISION CSH(4,MNC,MNSP)
*
*--(CSH(N,M,L) higher order sampling in cell M of species L
*----N=1 sum of u*v
*----N=2 sum of c**2*u
*----N=3 sum of rotl. energy*u
*
DOUBLE PRECISION CSS(8,2,MNSP)
*
*--CSS(N,M,L) sampled info. on the molecules striking the boundaries
*----M=1, 2 for the inner, outer boundaries; L is the species
*----N=1 the number sum
*----N=2 the sum of the normal momentum of the incident molecules
*----N=3 the sum of the normal momentum for the reflected molecules
*----N=4 the sum of the incident parallel momentum in the y direction
*----N=5 the sum of the incident translational energy
*----N=6 the sum of the reflected translational energy
*----N=7 the sum of the incident rotational energy
*----N=8 the sum of the reflected rotational energy
*
COMMON /MOLS / NM,PP(MNM),PV(3,MNM),IPL(MNM),IPS(MNM),IR(MNM)
*
*--variables as defined in DSMC0.FOR
*
COMMON /MOLSR / PR(MNM)
*
*--PR(M) is the rotational energy of molecule M
*
COMMON /CELLS1/ CC(MNC),CG(3,MNC),IC(2,MNC,MNSG),ISC(MNSC),
& CCG(2,MNC,MNSG,MNSG),ISCG(2,MNSC,MNSG),IG(2,MNSG),
& IFC,CWR,AP,RP
*
*--IFC 0,1 for uniform cell width, cell widths in geometric progression
*--CWR the ratio of cell width at outer boundary to that at inner bound.
*--variables as defined in DSMC0.FOR
*
COMMON /GAS / SP(5,MNSP),SPM(6,MNSP,MNSP),ISP(MNSP)
*
*--variables as defined in DSMC0.FOR
*
COMMON /GASR / SPR(3,MNSP,MNSP),ISPR(3,MNSP),CT(MNC)
*
*--variables as defined in DSMC0R.FOR
*
COMMON /SAMP / COL,NCOL,MOVT,SELT,SEPT,CS,TIME,NPR,NSMP,FND,FTMP,
& TIMI,FSP(MNSP),ISPD
*
*--variables as defined in DSMC0.FOR
*
COMMON /SAMPR / CSR
*
COMMON /SAMPS / CSS
*
COMMON /SAMPH / CSH
*--double precision variables defined above
*
COMMON /COMP / FNUM,DTM,NIS,NSP,NPS,NPT
*
*--variables as defined in DSMC0.FOR
*
COMMON /GEOM1 / IFX,NSC,XB(2),IB(2),BT(2),BVY(2),BFND(2),BFTMP(2),
& BVFX(2),BFSP(2,MNSP),BME(2,MNSP),BMR(2,MNSP),IIS,
& CW,FW,GRAV
*
*--IFX 0, 1, or 2 for plane, cylindrical, or spherical flow
*--IIS 0, 1, or 2 if the initial flow is a vacuum, uniform stream, or
*----a uniform gradient between the values at two solid surfaces
*--NSC the number of sub-cells per cell
*--XB(N) N=1, 2 the location of the inner, outer boundary
*--IB(N) N=1, 2 the type code for the inner, outer boundary
*--no further data is needed if IB=1, 2, or 5
*--if IB=3 (solid surface), the following info. is needed (N as above)
*--BT(N) the temperature of the surface
*--BVY(N) the y velocity component (valid for IFX= 0 or 1)
*--if IB=4 (external gas stream), the following info. (N as above)
*--BFND(N) the number density of the external stream
*--BFTMP(N) the temperature
*--BVFX(N) the x component of the velocity
*--BFSP(N,L) the fraction of species L in the stream
*--the following are non-data variables that can apply for IB=3, or 4
*--BME(N,L) the number of molecules of species L that enter at each DTM
*--BMR(N,L) the remainder associated with entry number
*--CW the cell width for uniform cells
*--FW the flow width
*--GRAV the gravitational acceleration in the x direction
*
COMMON /CONST / PI,SPI,BOLTZ
LOGICAL FLAG(MNM)
REAL INCI(MNM),SCATTER(MNM),TRACK(MNM),STRKPOS(MNM)
REAL SCATPOS(MNM)
COMMON FLAG,INCIDENT,SCATTER,TRACK,STRKPOS,SCATPOS
REAL NU_H(1000000),SPD(1000000)
COMMON /OUTERBOUN/ HCOND0,QAVE,NU_H,Q_CON,SPD
COMMON /LAWKEL/ SLOPE(100000)
REAL A(1000000)
*
*--variables as defined in DSMC0.FOR
*
c WRITE (*,*) ' INPUT 0,1 FOR CONTINUING,NEW CALCULATION:- '
c READ (*,*) NQL
c WRITE (*,*) ' INPUT 0,1 FOR CONTINUING,NEW SAMPLE:- '
c READ (*,*) NQLS
*
OPEN (4,FILE='./INPUT1.DAT',STATUS='OLD')
READ (4,*) NQL
CLOSE (4)
OPEN (4,FILE='./INPUT2.DAT',STATUS='OLD')
READ (4,*) NQLS
CLOSE (4)
*
IF (NQL.EQ.1) THEN
*
CALL INIT1
*
ELSE
*
WRITE (*,*) ' READ THE RESTART FILE'
OPEN (4,FILE='unun.RES',STATUS='OLD',FORM='UNFORMATTED')
READ (4) AP,BFND,BFSP,BFTMP,BME,BMR,BOLTZ,BT,BVFX,BVY,CC,CCG,CG,
& COL,CS,CSH,CSR,CSS,CT,CW,CWR,DTM,FNUM,FTMP,FW,GRAV,IB,
& IC,IFC,IFX,IIS,IPL,IPS,IR,ISC,ISCG,ISP,ISPR,MOVT,NCOL,
& NIS,NM,NPS,NSC,NSMP,NPR,NPT,NSP,PI,PP,PR,PV,RP,SELT,
& SEPT,SP,SPI,SPM,SPR,TIME,TIMI,XB
CLOSE (4)
*
END IF
*
IF (NQLS.EQ.1) CALL SAMPI1
*
100 NPR=NPR+1
*
c IF (NPR.LE.NPS) CALL SAMPI1
*
L=NPR
A(L)=REAL(NPR)/REAL(NPS)
c OPEN(4,FILE='A.txt',FORM='FORMATTED')
c DO I=1,NPR
c WRITE(4,999) I, A(I)
c END DO
c 999 FORMAT (' ',I16,1P,E12.4)
*
IF (ABS(A(L)-1.).LT.1.E-6) CALL SAMPI1
IF (ABS(A(L)-2.).LT.1.E-6) CALL SAMPI1
IF (ABS(A(L)-3.).LT.1.E-6) CALL SAMPI1
IF (MOD(NPR,100).EQ.0.0) CALL LAWKELTON(NPR/100)
* IF (ABS(A(L)-4.).LT.1.E-6) CALL SAMPI1
* IF (ABS(A(L)-5.).LT.1.E-6) CALL SAMPI1
* IF (ABS(A(L)-6.).LT.1.E-6) CALL SAMPI1
* IF (ABS(A(L)-7.).LT.1.E-6) CALL SAMPI1
* IF (ABS(A(L)-8.).LT.1.E-6) CALL SAMPI1
* IF (ABS(A(L)-9.).LT.1.E-6) CALL SAMPI1
* IF (ABS(A(L)-10.).LT.1.E-6) CALL SAMPI1
* IF (ABS(A(L)-11.).LT.1.E-6) CALL SAMPI1
*
DO 200 JJJ=1,NSP
DO 150 III=1,NIS
TIME=TIME+DTM
*
WRITE (*,99001) III,JJJ,NIS,NSP,NM,IDINT(NCOL)
99001 FORMAT (' DSMC1:- Move',2I5,' of',2I5,I8,' Mols',I14,' Colls')
*
CALL MOVE1
*
CALL INDEXM
*
CALL COLLMR
*
150 CONTINUE
*
CALL SAMPLE1
*
200 CONTINUE
*
WRITE (*,*) ' WRITING RESTART AND OUTPUT FILES',NPR,' OF ',NPT
OPEN (4,FILE='unun.RES',FORM='UNFORMATTED')
WRITE (4) AP,BFND,BFSP,BFTMP,BME,BMR,BOLTZ,BT,BVFX,BVY,CC,CCG,CG,
& COL,CS,CSH,CSR,CSS,CT,CW,CWR,DTM,FNUM,FTMP,FW,GRAV,IB,
& IC,IFC,IFX,IIS,IPL,IPS,IR,ISC,ISCG,ISP,ISPR,MOVT,NCOL,
& NIS,NM,NPS,NSC,NSMP,NPR,NPT,NSP,PI,PP,PR,PV,RP,SELT,
& SEPT,SP,SPI,SPM,SPR,TIME,TIMI,XB
CLOSE (4)
*
N_NU_H=NPR
*
CALL OUT1(N_NU_H)
IF (NPR.LT.NPT) GO TO 100
STOP
END
* INIT1.FOR
*
SUBROUTINE INIT1
*
PARAMETER (MNM=600000,MNC=2000,MNSC=40000,MNSP=1,MNSG=1)
*
DOUBLE PRECISION COL(MNSP,MNSP),MOVT,NCOL,SELT,SEPT,CS(7,MNC,MNSP)
DOUBLE PRECISION CSR(MNC,MNSP)
*
COMMON /MOLS / NM,PP(MNM),PV(3,MNM),IPL(MNM),IPS(MNM),IR(MNM)
COMMON /MOLSR / PR(MNM)
COMMON /CELLS1/ CC(MNC),CG(3,MNC),IC(2,MNC,MNSG),ISC(MNSC),
& CCG(2,MNC,MNSG,MNSG),ISCG(2,MNSC,MNSG),IG(2,MNSG),
& IFC,CWR,AP,RP
COMMON /GAS / SP(5,MNSP),SPM(6,MNSP,MNSP),ISP(MNSP)
COMMON /GASR / SPR(3,MNSP,MNSP),ISPR(3,MNSP),CT(MNC)
COMMON /SAMP / COL,NCOL,MOVT,SELT,SEPT,CS,TIME,NPR,NSMP,FND,FTMP,
& TIMI,FSP(MNSP),ISPD
COMMON /SAMPR / CSR
COMMON /COMP / FNUM,DTM,NIS,NSP,NPS,NPT
COMMON /GEOM1 / IFX,NSC,XB(2),IB(2),BT(2),BVY(2),BFND(2),BFTMP(2),
& BVFX(2),BFSP(2,MNSP),BME(2,MNSP),BMR(2,MNSP),IIS,
& CW,FW,GRAV
COMMON /CONST / PI,SPI,BOLTZ
*
*--set constants
*
PI=3.141592654
SPI=SQRT(PI)
BOLTZ=1.380622E-23
*
*--set data variables to default values that they retain if the data
*----does not reset them to specific values
NSC=MNSC/MNC
FND=0.
FTMP=273.
GRAV=0.
IFC=1
DO 100 N=1,2
XB(N)=0.
IB(N)=5
BT(N)=0.
BVY(N)=0.
BFND(N)=0.
BFTMP(N)=0.
BVFX(N)=0.
DO 50 L=1,MNSP
ISP(L)=1
FSP(L)=0.
BFSP(N,L)=0.
BME(N,L)=0.
BMR(N,L)=0.
50 CONTINUE
100 CONTINUE
*
CALL DATA1
*
*--set additional data on the gas
*
IF (MNSP.EQ.1) ISPD=0
DO 200 N=1,MNSP
DO 150 M=1,MNSP
IF ((ISPR(3,N).EQ.0).AND.(M.NE.N)) THEN
SPR(1,N,M)=SPR(1,N,N)
SPR(2,N,M)=SPR(2,N,N)
SPR(3,N,M)=SPR(3,N,N)
END IF
IF ((ISPD.EQ.0).OR.(N.EQ.M)) THEN
SPM(1,N,M)=0.25*PI*(SP(1,N)+SP(1,M))**2
*--the collision cross section is assumed to be given by eqn (1.35)
SPM(2,N,M)=0.5*(SP(2,N)+SP(2,M))
SPM(3,N,M)=0.5*(SP(3,N)+SP(3,M))
SPM(4,N,M)=0.5*(SP(4,N)+SP(4,M))
*--mean values are used for ISPD=0
ELSE
SPM(1,N,M)=PI*SPM(1,N,M)**2
*--the cross-collision diameter is converted to the cross-section
END IF
SPM(5,N,M)=(SP(5,N)/(SP(5,N)+SP(5,M)))*SP(5,M)
*--the reduced mass is defined in eqn (2.7)
SPM(6,N,M)=GAM(2.5-SPM(3,N,M))
150 CONTINUE
200 CONTINUE
*
*--initialise variables
*
TIME=0.
NM=0
NPR=0
NCOL=0
MOVT=0.
SELT=0.
SEPT=0.
CWR=100
*
DO 300 M=1,MNSP
DO 250 N=1,MNSP
COL(M,N)=0.
250 CONTINUE
300 CONTINUE
*
FW=XB(2)-XB(1)
CG(1,1)=XB(1)
IF (IFC.EQ.0) THEN
CW=FW/MNC
*--CW is the uniform cell width
ELSE
RP=CWR**(1./(MNC-1.))
*--RP is the ratio in the geometric progression
AP=(1.-RP)/(1.-RP**MNC)
*--AP is the first term of the progression
END IF
DO 400 M=1,MNC
CT(M)=FTMP
*--the macroscopic temperature is set to the freestream temperature
IF (M.GT.1) CG(1,M)=CG(2,M-1)
IF (IFC.EQ.0) THEN
CG(2,M)=CG(1,M)+CW
ELSE
CG(2,M)=CG(1,M)+FW*AP*RP**(M-1)
END IF
CG(3,M)=CG(2,M)-CG(1,M)
IF (IFX.EQ.0) CC(M)=CG(3,M)
*--a plane flow has unit cross-sectional area
IF (IFX.EQ.1) CC(M)=PI*(CG(2,M)**2-CG(1,M)**2)
*--a cylindrical flow has unit length in the axial direction
IF (IFX.EQ.2) CC(M)=(4./3.)*PI*(CG(2,M)**3-CG(1,M)**3)
*--a spherical flow occupies the full sphere
DO 350 L=1,MNSG
DO 320 K=1,MNSG
CCG(2,M,L,K)=RF(0)
CCG(1,M,L,K)=SPM(1,1,1)*300.*SQRT(FTMP/300.)
320 CONTINUE
350 CONTINUE
*--the maximum value of the (rel. speed)*(cross-section) is set to a
*--reasonable, but low, initial value and will be increased as necessary
400 CONTINUE
IF (IFC.EQ.1) THEN
AP=(1.-RP)/AP
RP=LOG(RP)
*--AP and RP are now the convenient terms in eqn (12.1)
END IF
*
*--set sub-cells
*
DO 500 N=1,MNC
DO 450 M=1,NSC
L=(N-1)*NSC+M
ISC(L)=N
450 CONTINUE
500 CONTINUE
*
IF (IIS.GT.0) THEN
*--if IIS=1 generate initial gas with temperature FTMP, or
*--if IIS=2 generate initial gas as a uniform gradient between two
*----surfaces (valid only if IB(1)=3 and IB(2)=3)
*
IF (IIS.EQ.2.AND.(IB(1).NE.3.OR.IB(2).NE.3)) THEN
WRITE (*,*) ' IIS=2 IS AN ILLEGAL OPTION IN THIS CASE '
STOP
END IF
DO 550 L=1,MNSP
REM=0
IF (IIS.EQ.1) VMP=SQRT(2.*BOLTZ*FTMP/SP(5,L))
*--VMP is the most probable speed in species L, see eqns (4.1) and (4.7)
DO 520 N=1,MNC
IF (IIS.EQ.2) THEN
PROP=(N-0.5)/FLOAT(MNC)
VELS=BVY(1)+PROP*(BVY(2)-BVY(1))
TMPS=BT(1)+PROP*(BT(2)-BT(1))
FNDS=FND*0.5*(BT(1)+BT(2))/TMPS
VMP=SQRT(2.*BOLTZ*TMPS/SP(5,L))
ELSE
FNDS=FND
TMPS=FTMP
END IF
A=FNDS*CC(N)*FSP(L)/FNUM+REM
*--A is the number of simulated molecules of species L in cell N to
*--simulate the required concentrations at a total number density of FND
IF (N.LT.MNC) THEN
MM=A
REM=(A-MM)
*--the remainder REM is carried forward to the next cell
ELSE
MM=NINT(A)
END IF
IF (MM.GT.0) THEN
DO 505 M=1,MM
IF (NM.LT.MNM) THEN
*--round-off error could have taken NM to MNM+1
NM=NM+1
IPS(NM)=L
IF (IFX.EQ.0) PP(NM)=CG(1,N)+RF(0)*(CG(2,N)-CG(1,N))
IF (IFX.EQ.1) PP(NM)=SQRT(CG(1,N)**2+RF(0)*(CG(2,N)**2
& -CG(1,N)**2))
IF (IFX.EQ.2) PP(NM)=(CG(1,N)**3+RF(0)*(CG(2,N)**3-CG(
& 1,N)**3))**0.3333333
IPL(NM)=(PP(NM)-CG(1,N))*(NSC-.001)/CG(3,N)
& +1+NSC*(N-1)
*--species, position, and sub-cell number have been set
DO 502 K=1,3
CALL RVELC(PV(K,NM),A,VMP)
502 CONTINUE
IF (IIS.EQ.2) PV(2,NM)=PV(2,NM)+VELS
*--velocity components have been set
*--set the rotational energy
IF (ISPR(1,L).GT.0) CALL SROT(PR(NM),TMPS,ISPR(1,L))
END IF
505 CONTINUE
END IF
520 CONTINUE
550 CONTINUE
END IF
*
WRITE (*,99001) NM
99001 FORMAT (' ',I6,' MOLECULES')
*
*--calculate the number of molecules that enter at each time step
DO 600 N=1,2
IF (IB(N).EQ.4) THEN
*--the entry molecules are from an external stream
DO 560 L=1,MNSP
VMP=SQRT(2.*BOLTZ*BFTMP(N)/SP(5,L))
*--VMP is the most probable speed in species L, see eqns (4.1) and (4.7)
IF (N.EQ.1) SC=BVFX(N)/VMP
IF (N.EQ.2) SC=-BVFX(N)/VMP
*--SC is the inward directed speed ratio
IF (ABS(SC).LT.10.1) A=(EXP(-SC*SC)+SPI*SC*(1.+ERF(SC)))
& /(2.*SPI)
IF (SC.GT.10.) A=SC
IF (SC.LT.-10.) A=0.
*--A is the non-dimensional flux of eqn (4.22)
IF (IFX.EQ.1) A=A*2.*PI*XB(N)
IF (IFX.EQ.2) A=A*4.*PI*XB(N)**2
BME(N,L)=BFND(N)*BFSP(N,L)*A*VMP*DTM/FNUM
WRITE (*,*) ' entering mols ',BME(N,L)
560 CONTINUE
END IF
600 CONTINUE
RETURN
END
* MOVE1.FOR
*
SUBROUTINE MOVE1
*
*--the NM molecules are moved over the time interval DTM
*
PARAMETER (MNM=600000,MNC=2000,MNSC=40000,MNSP=1,MNSG=1)
*
DOUBLE PRECISION COL(MNSP,MNSP),MOVT,NCOL,SELT,SEPT,CS(7,MNC,MNSP)
DOUBLE PRECISION CSS(8,2,MNSP)
*
COMMON /MOLS / NM,PP(MNM),PV(3,MNM),IPL(MNM),IPS(MNM),IR(MNM)
COMMON /MOLSR / PR(MNM)
COMMON /CELLS1/ CC(MNC),CG(3,MNC),IC(2,MNC,MNSG),ISC(MNSC),
& CCG(2,MNC,MNSG,MNSG),ISCG(2,MNSC,MNSG),IG(2,MNSG),
& IFC,CWR,AP,RP
COMMON /GAS / SP(5,MNSP),SPM(6,MNSP,MNSP),ISP(MNSP)
COMMON /GASR / SPR(3,MNSP,MNSP),ISPR(3,MNSP),CT(MNC)
COMMON /SAMP / COL,NCOL,MOVT,SELT,SEPT,CS,TIME,NPR,NSMP,FND,FTMP,
& TIMI,FSP(MNSP),ISPD
COMMON /SAMPS / CSS
COMMON /COMP / FNUM,DTM,NIS,NSP,NPS,NPT
COMMON /GEOM1 / IFX,NSC,XB(2),IB(2),BT(2),BVY(2),BFND(2),BFTMP(2),
& BVFX(2),BFSP(2,MNSP),BME(2,MNSP),BMR(2,MNSP),IIS,
& CW,FW,GRAV
COMMON /CARTE/ XPOS(MNM),YPOS(MNM),ZPOS(MNM),RPOS(MNM)
REAL MFP(MNM),NUMMFP(MNM)
COMMON /MFPTEST/ MFP,NUMMFP
COMMON /STRIKE/ FLAG(MNM),INCI(MNM),SCATTER(MNM),TRACK(MNM),
& STRKPOS(MNM),SCATPOS(MNM)
COMMON /MOAR/ NFLAG(MNM),RLV(MNM)
*
IF (ABS(GRAV).GT.1.E-6) THEN
IGRAV=1
ELSE
IGRAV=0
END IF
IFT=-1
*--a negative IFT indicates that molecules have not entered at this step
N=0
100 N=N+1
IF (N.LE.NM) THEN
IF (IFT.LT.0) AT=DTM
IF (IFT.GT.0) AT=RF(0)*DTM
*--the time step is a random fraction of DTM for entering molecules
150 MOVT=MOVT+1
MSC=IPL(N)
MC=ISC(MSC)
*--MC is the initial cell number
XI=PP(N)
c IF ((XI+0.00001*CG(3,1)).LT.XB(1).OR.
c & (XI-0.00001*CG(3,MNC)).GT.XB(2)) THEN
c WRITE (*,*) ' MOL ',N,' OUTSIDE FLOW ',XI
c CALL REMOVE(N)
c GO TO 100
c END IF
IF ((XI+0.00001*CG(3,1)).LT.XB(1))THEN
CALL REFLECT1(N,1)
INCI(N)=INCI(N)+1.D00
GO TO 100
END IF
IF ((XI-0.00001*CG(3,MNC)).GT.XB(2))THEN
CALL REFLECT1(N,2)
GO TO 100
END IF
c Added by SH 07/10
DX=PV(1,N)*AT
IF (IGRAV.EQ.1) DX=DX+0.5*GRAV*AT*AT
IF (IFX.GT.0) DY=PV(2,N)*AT
IF (IFX.EQ.2) DZ=PV(3,N)*AT
X=XI+DX
c
IF (FLAG(N).EQ.1) THEN
XPOS(N)=XPOS(N)+ABS(DX)
YPOS(N)=YPOS(N)+ABS(DY)
ZPOS(N)=ZPOS(N)+ABS(DZ)
RPOS(N)=RPOS(N)+SQRT(DX*DX+DY*DY+DZ*DZ)
END IF
IF (NFLAG(N).EQ.1) THEN
RLV(N)=RLV(N)+SQRT(DX*DX+DY*DY+DZ*DZ)
END IF
c Added by SH 07/11
IF (IFX.NE.0) THEN
*--cylindrical or spherical flow
*--first check for inner boundary interactions
IF (IB(1).NE.1) THEN
*--there can be no interaction with an axis or centre
IF (X.LT.XB(1)) THEN
CALL RBC(IFX,XI,DX,DY,DZ,XB(1),S1)
IF (S1.LT.1.) THEN
*--collision with inner boundary
IF (IB(1).GT.3) THEN
*--molecule leaves flow
CALL REMOVE(N)
GO TO 100
END IF
DX=S1*DX
DY=S1*DY
DZ=S1*DZ
CALL AIFX(IFX,XI,DX,DY,DZ,XC,PV(1,N),PV(2,N),PV(3,N))
*--the frame of reference has been rotated with regard to the point of
*----intersection with the inner surface
IF (IB(1).EQ.2) THEN
*--specular reflection from the boundary
PV(1,N)=-PV(1,N)
PP(N)=XB(1)+0.001*CG(3,1)
AT=AT*(1.-S1)
GO TO 150
END IF
IF (IB(1).EQ.3) THEN
*--molecule reflects from the surface
CALL REFLECT1(N,1)
*--AT is the remaining in the time step for this molecule
AT=AT*(1.-S1)
GO TO 150
END IF
END IF
END IF
END IF
RR=X*X+DY*DY+(IFX-1)*DZ*DZ
IF (RR.GT.XB(2)*XB(2)) THEN
*--interaction with the outer boundary
CALL RBC(IFX,XI,DX,DY,DZ,XB(2),S1)
IF (S1.LT.1.) THEN
*--collision with outer boundary
IF (IB(2).EQ.4.OR.IB(2).EQ.5) THEN
*--molecule leaves flow
CALL REMOVE(N)
GO TO 100
END IF
*
IF (IB(2).EQ.6) THEN
c CALL REENTER(N)
GO TO 100
END IF
*
DX=S1*DX
DY=S1*DY
DZ=S1*DZ
CALL AIFX(IFX,XI,DX,DY,DZ,XC,PV(1,N),PV(2,N),PV(3,N))
*--the frame of reference has been rotated with regard to the point of
*----intersection with the outer surface
IF (IB(2).EQ.2) THEN
*--specular reflection from the boundary
PV(1,N)=-PV(1,N)
PP(N)=XB(1)+0.001*CG(3,1)
AT=AT*(1.-S1)
GO TO 150
END IF
IF (IB(2).EQ.3) THEN
*--molecule reflects from the surface
CALL REFLECT1(N,2)
*--AT is the remaining in the time step for this molecule
AT=AT*(1.-S1)
GO TO 150
END IF
END IF
END IF
*--calculate the end of the trajectory
CALL AIFX(IFX,XI,DX,DY,DZ,X,PV(1,N),PV(2,N),PV(3,N))
* plane flow
*--molecule N at XI is moved by DX to X
ELSE IF (X.LT.XB(1).OR.X.GT.XB(2)) THEN
IF (X.LT.XB(1)) K=1
IF (X.GT.XB(2)) K=2
*--intersection with inner, outer boundary for K=1, 2
IF (IB(K).EQ.2) THEN
*--specular reflection from the boundary (eqn (11.7))
X=2.*XB(K)-X
PV(1,N)=-PV(1,N)
END IF
IF (IB(K).GT.3) THEN
*--molecule leaves flow
* CALL REMOVE(N)
GO TO 100
END IF
IF (IB(K).EQ.3) THEN
*--AT is the remaining in the time step for this molecule
AT=AT-(XB(K)-XI)/PV(1,N)
*--molecule reflects from the surface
CALL REFLECT1(N,K)
GO TO 150
END IF
*--no boundary interactions
END IF
*
IF (X.LT.CG(1,MC).OR.X.GT.CG(2,MC)) THEN
*--the molecule has moved from the initial cell
IF (IFC.EQ.0) THEN
MC=(X-XB(1))/CW+0.99999
ELSE
XD=(X-XB(1))/FW+1.E-6
MC=1.+(LOG(1.-XD*AP))/RP
*--the cell number is calculated from eqn (12.1)
END IF
IF (MC.LT.1) MC=1
IF (MC.GT.MNC) MC=MNC
*--MC is the new cell number (note avoidance of round-off error)
END IF
MSC=((X-CG(1,MC))/CG(3,MC))*(NSC-.001)+1+NSC*(MC-1)
*--MSC is the new sub-cell number
IF (MSC.LT.1) MSC=1
IF (MSC.GT.MNSC) MSC=MNSC
IPL(N)=MSC
PP(N)=X
IF (IGRAV.EQ.1) PV(1,N)=PV(1,N)+GRAV*AT
GO TO 100
ELSE IF (IFT.LT.0) THEN
IFT=1
*--new molecules enter
CALL ENTER1
N=N-1
GO TO 100
END IF
RETURN
END
* ENTER1.FOR
*
SUBROUTINE ENTER1
*
*--new molecules enter at boundaries
*
PARAMETER (MNM=600000,MNC=2000,MNSC=40000,MNSP=1,MNSG=1)
*
DOUBLE PRECISION COL(MNSP,MNSP),MOVT,NCOL,SELT,SEPT,CS(7,MNC,MNSP)
*
COMMON /MOLS / NM,PP(MNM),PV(3,MNM),IPL(MNM),IPS(MNM),IR(MNM)
COMMON /MOLSR / PR(MNM)
COMMON /CELLS1/ CC(MNC),CG(3,MNC),IC(2,MNC,MNSG),ISC(MNSC),
& CCG(2,MNC,MNSG,MNSG),ISCG(2,MNSC,MNSG),IG(2,MNSG),
& IFC,CWR,AP,RP
COMMON /GAS / SP(5,MNSP),SPM(6,MNSP,MNSP),ISP(MNSP)
COMMON /GASR / SPR(3,MNSP,MNSP),ISPR(3,MNSP),CT(MNC)
COMMON /SAMP / COL,NCOL,MOVT,SELT,SEPT,CS,TIME,NPR,NSMP,FND,FTMP,
& TIMI,FSP(MNSP),ISPD
COMMON /COMP / FNUM,DTM,NIS,NSP,NPS,NPT
COMMON /GEOM1 / IFX,NSC,XB(2),IB(2),BT(2),BVY(2),BFND(2),BFTMP(2),
& BVFX(2),BFSP(2,MNSP),BME(2,MNSP),BMR(2,MNSP),IIS,
& CW,FW,GRAV
COMMON /CONST / PI,SPI,BOLTZ
*
DO 100 N=1,2
*--consider each boundary in turn
DO 50 L=1,MNSP
*--consider each species in turn
A=BME(N,L)+BMR(N,L)
M=A
BMR(N,L)=A-M
* WRITE (*,99010) A,BMR(N,L)
*99010 FORMAT ('A',E12.4,' BMR',E12.4)
*--M molecules enter, remainder has been reset
IF (M.GT.0) THEN
VMP=SQRT(2.*BOLTZ*BFTMP(N)/SP(5,L))
IF (ABS(BVFX(N)).GT.1.E-6) THEN
IF (N.EQ.1) SC=BVFX(N)/VMP
IF (N.EQ.2) SC=-BVFX(N)/VMP
FS1=SC+SQRT(SC*SC+2.)
FS2=0.5*(1.+SC*(2.*SC-FS1))
END IF
* the above constants are required for the entering distn. of eqn (12.5)
DO 10 K=1,M
IF (NM.LT.MNM) THEN
NM=NM+1
*--NM is now the number of the new molecule
IF (ABS(BVFX(N)).GT.1.E-6) THEN
QA=3.
IF (SC.LT.-3.) QA=ABS(SC)+1.
2 U=-QA+2.*QA*RF(0)
*--U is a potential normalised thermal velocity component
UN=U+SC
*--UN is a potential inward velocity component
IF (UN.LT.0.) GO TO 2
A=(2.*UN/FS1)*EXP(FS2-U*U)
IF (A.LT.RF(0)) GO TO 2
*--the inward normalised vel. component has been selected (eqn (12.5))
IF (N.EQ.1) PV(1,NM)=UN*VMP
IF (N.EQ.2) PV(1,NM)=-UN*VMP
ELSE
IF (N.EQ.1) PV(1,NM)=SQRT(-LOG(RF(0)))*VMP
IF (N.EQ.2) PV(1,NM)=-SQRT(-LOG(RF(0)))*VMP
*--for a stationary external gas, use eqn (12.3)
END IF
CALL RVELC(PV(2,NM),PV(3,NM),VMP)
*--a single call of RVELC generates the two normal velocity components
IF (ISPR(1,L).GT.0) CALL SROT(PR(NM),BFTMP(N),ISPR(1,L))
IF (N.EQ.1) PP(NM)=XB(1)+0.001*CG(3,1)
IF (N.EQ.2) PP(NM)=XB(2)-0.001*CG(3,MNC)
*--the molecule is moved just off the boundary
IPS(NM)=L
IF (N.EQ.1) IPL(NM)=1
IF (N.EQ.2) IPL(NM)=MNSC
ELSE
WRITE (*,*)
&' WARNING: EXCESS MOLECULE LIMIT - RESTART WITH AN INCREASED FNUM'
END IF
10 CONTINUE
END IF
50 CONTINUE
100 CONTINUE
RETURN
END
* REFLECT1.FOR
SUBROUTINE REFLECT1(N,K)
*
*--diffuse reflection of molecule N from surface K
*
PARAMETER (MNM=600000,MNC=2000,MNSC=40000,MNSP=1,MNSG=1)
*
DOUBLE PRECISION COL(MNSP,MNSP),MOVT,NCOL,SELT,SEPT,CS(7,MNC,MNSP)
DOUBLE PRECISION CSS(8,2,MNSP)
*
COMMON /MOLS / NM,PP(MNM),PV(3,MNM),IPL(MNM),IPS(MNM),IR(MNM)
COMMON /MOLSR / PR(MNM)
COMMON /CELLS1/ CC(MNC),CG(3,MNC),IC(2,MNC,MNSG),ISC(MNSC),
& CCG(2,MNC,MNSG,MNSG),ISCG(2,MNSC,MNSG),IG(2,MNSG),
& IFC,CWR,AP,RP
COMMON /GAS / SP(5,MNSP),SPM(6,MNSP,MNSP),ISP(MNSP)
COMMON /GASR / SPR(3,MNSP,MNSP),ISPR(3,MNSP),CT(MNC)
COMMON /SAMP / COL,NCOL,MOVT,SELT,SEPT,CS,TIME,NPR,NSMP,FND,FTMP,
& TIMI,FSP(MNSP),ISPD
COMMON /SAMPS / CSS
COMMON /COMP / FNUM,DTM,NIS,NSP,NPS,NPT
COMMON /GEOM1 / IFX,NSC,XB(2),IB(2),BT(2),BVY(2),BFND(2),BFTMP(2),
& BVFX(2),BFSP(2,MNSP),BME(2,MNSP),BMR(2,MNSP),IIS,
& CW,FW,GRAV
COMMON /CONST / PI,SPI,BOLTZ
COMMON /INNERBOUN/ ALFNORM,ALFTANG
COMMON /STRIKE/ FLAG(MNM),INCI(MNM),SCATTER(MNM),TRACK(MNM),
& STRKPOS(MNM),SCATPOS(MNM)
COMMON /CARTE/ XPOS(MNM),YPOS(MNM),ZPOS(MNM),RPOS(MNM)
COMMON /MOAR/ NFLAG(MNM),RLV(MNM)
*
L=IPS(N)
*--sample the surface properies due to the incident molecules
CSS(1,K,L)=CSS(1,K,L)+1.
IF (K.EQ.1) CSS(2,K,L)=CSS(2,K,L)-SP(5,L)*PV(1,N)
IF (K.EQ.2) CSS(2,K,L)=CSS(2,K,L)+SP(5,L)*PV(1,N)
CSS(4,K,L)=CSS(4,K,L)+SP(5,L)*(PV(2,N)-BVY(K))
CSS(5,K,L)=CSS(5,K,L)+0.5*SP(5,L)
& *(PV(1,N)**2+(PV(2,N)-BVY(K))**2+PV(3,N)**2)
CSS(7,K,L)=CSS(7,K,L)+PR(N)
*
VMP=SQRT(2.*BOLTZ*BT(K)/SP(5,L))
VMG=SQRT(2.*BOLTZ*BT(2)/SP(5,L))
*--VMP is the most probable speed in species L, see eqns (4.1) and (4.7)
c IF (K.EQ.1) THEN
c PV(1,N)=SQRT(-LOG(RF(0)))*VMP
c CALL RVELC(PV(2,N),PV(3,N),VMP)
c STRKPOS(N)=ABS(PP(N)-TRACK(N))
c FLAG(N)=1
c SCATPOS(N)=PP(N)
c END IF
IF (K.EQ.1) THEN
IF ((RF(0)-0.3).GT.1.E-9) THEN
PV(1,N)=-PV(1,N)
ELSE
PV(1,N)=SQRT(-LOG(RF(0)))*VMP
CALL RVELC(PV(2,N),PV(3,N),VMP)
END IF
STRKPOS(N)=ABS(PP(N)-TRACK(N))
FLAG(N)=1
NFLAG(N)=0
INCI(N)=INCI(N)+1
SCATPOS(N)=PP(N)
END IF
c IF (K.EQ.1) THEN
c IF((RF(0)-ALFNORM).GT.1.E-6) THEN
c PV(1,N)=-PV(1,N)
c ELSE
c CALL CLL(PV(1,N),PV(2,N),PV(3,N),VMP)
c END IF
c CALL RVELC(PV(2,N),PV(3,N),VMP)
c STRKPOS(N)=ABS(PP(N)-TRACK(N))
c FLAG(N)=1
c SCATPOS(N)=PP(N)
c END IF
c Added by SH
IF (K.EQ.2) THEN
PV(1,N)=-SQRT(-LOG(RF(0)))*VMP
*--the normal velocity component has been generated (eqn(12.3))
CALL RVELC(PV(2,N),PV(3,N),VMP)
*--a single call of RVELC generates the two tangential velocity components
END IF
PV(2,N)=PV(2,N)+BVY(K)
IF (ISPR(1,L).GT.0) CALL SROT(PR(N),BT(K),ISPR(1,L))
IF (K.EQ.1) PP(N)=XB(1)+0.001*CG(3,1)
IF (K.EQ.2) PP(N)=XB(2)-0.001*CG(3,MNC)
*--the molecule is moved just off the boundary
IF (K.EQ.1) IPL(N)=1
IF (K.EQ.2) IPL(N)=MNSC
*--sample the surface properties due to the reflected molecules
IF (K.EQ.1) CSS(3,K,L)=CSS(3,K,L)+SP(5,L)*PV(1,N)
IF (K.EQ.2) CSS(3,K,L)=CSS(3,K,L)-SP(5,L)*PV(1,N)
CSS(6,K,L)=CSS(6,K,L)-0.5*SP(5,L)
& *(PV(1,N)**2+(PV(2,N)-BVY(K))**2+PV(3,N)**2)
CSS(8,K,L)=CSS(8,K,L)-PR(N)
RETURN
END
* REMOVE.FOR
SUBROUTINE REMOVE(N)
*
*--remove molecule N and replace it by molecule NM
*
PARAMETER (MNM=600000,MNC=2000,MNSC=40000,MNSP=1,MNSG=1)
*
*
COMMON /MOLS / NM,PP(MNM),PV(3,MNM),IPL(MNM),IPS(MNM),IR(MNM)
COMMON /MOLSR / PR(MNM)
*
PP(N)=PP(NM)
DO 100 M=1,3