summaryrefslogtreecommitdiff
path: root/Dragon/src/MCGSCS.f
blob: 92f07aa2df6a6928008c2c0f80607fdd0805dbf6 (plain)
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
*DECK MCGSCS
      SUBROUTINE MCGSCS(KPN,K,NREG,M,NANI,NFUNL,NPJJM,KEYFLX,KEYANI,
     1                  PJJIND,NZON,XSW,PJJ,AR,PSI,MATRIX)
*
*-----------------------------------------------------------------------
*
*Purpose:
* Solve the SCR anisotropic system.
*
*Copyright:
* Copyright (C) 2002 Ecole Polytechnique de Montreal
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version
*
*Author(s): R. Le Tellier
*
*Parameters: input
* KPN     total number of unknowns in vectors SUNKNO and FUNKNO.
* K       total number of volumes for which specific values
*         of the neutron flux and reactions rates are required.
* NREG    number of volumes.
* M       number of material mixtures.
* NANI    scattering anisotropy (=1 for isotropic scattering).
* NFUNL   number of moments of the flux (in 2D : NFUNL=NANI*(NANI+1)/2).
* NPJJM   second dimension of PJJ.
* KEYFLX  position of flux elements in FI vector.
* KEYANI  'mode to l' index l=KEYANI(nu).
* PJJIND  index for pjj(nu <- nu') modes.
* NZON    index-number of the mixture type assigned to each volume.
* XSW     macroscopic scattering cross section.
* PJJ     used in scr acceleration.
* AR      residuals of the current iteration.
*
*Parameters: output
* PSI     corrective flux.
*
*Parameters: scratch
* MATRIX  undefined.
*
*-----------------------------------------------------------------------
*
      IMPLICIT NONE
*----
*  SUBROUTINE ARGUMENTS
*----
      INTEGER KPN,K,NREG,M,NANI,NFUNL,NPJJM,KEYFLX(NREG,NPJJM),
     1 KEYANI(NFUNL),PJJIND(NPJJM,2),NZON(K)
      REAL XSW(0:M,NANI),PJJ(NREG,NPJJM),MATRIX(NFUNL,NFUNL+1,NREG)
      DOUBLE PRECISION AR(KPN),PSI(KPN)
*---
*  LOCAL VARIABLES
*---
      INTEGER IRHS,I,INU,IMOD,INUP,L,LP,L1,LP1,NZI,IND,INDP,IER
      REAL DL,DLP,XSWI,XSWIP,TEMP
*---
* CONSTRUCT LINEAR SYSTEM BY REGION TO SOLVE
*---
      IRHS=NFUNL+1
      MATRIX(:NFUNL,:NFUNL+1,:NREG)=0.0
      DO 10 IMOD=1,NPJJM
         INU=PJJIND(IMOD,1)
         INUP=PJJIND(IMOD,2)
         IF((INU.GT.NFUNL).OR.(INUP.GT.NFUNL)) GOTO 10
         L=KEYANI(INU)
         L1=L+1
         LP=KEYANI(INUP)
         LP1=LP+1
         DL=REAL(2*L+1)
         DLP=REAL(2*LP+1)
         DO I=1,NREG
            NZI=NZON(I)
            IND=KEYFLX(I,INU)
            INDP=KEYFLX(I,INUP)
            XSWI=XSW(NZI,L1)
            XSWIP=XSW(NZI,LP1)
            TEMP=PJJ(I,IMOD)
            MATRIX(INU,IRHS,I)=MATRIX(INU,IRHS,I)+TEMP*REAL(AR(INDP))
            MATRIX(INU,INUP,I)=-DLP*XSWIP*TEMP
            IF(INU.EQ.INUP) THEN
              MATRIX(INU,INUP,I)=MATRIX(INU,INUP,I)+1.0
            ELSE
              MATRIX(INUP,IRHS,I)=MATRIX(INUP,IRHS,I)+TEMP*REAL(AR(IND))
              MATRIX(INUP,INU,I)=-DL*XSWI*TEMP
            ENDIF
         ENDDO
 10   CONTINUE
*---
* SOLVE LINEAR SYSTEM BY REGION
*---
      DO I=1,NREG
         CALL ALSB(NFUNL,1,MATRIX(1,1,I),IER,NFUNL)
         IF(IER.NE.0) CALL XABORT('MCGSCS: SINGULAR MATRIX.')
         DO INU=1,NFUNL
            IND=KEYFLX(I,INU)
            PSI(IND)=MATRIX(INU,IRHS,I)
         ENDDO
      ENDDO
*
      RETURN
      END