V3FIT
load_modular_coils.f
1  SUBROUTINE load_modular_coils (nvariables, xvariables)
2 !-----------------------------------------------
3 ! M o d u l e s
4 !-----------------------------------------------
5  USE modular_coils
6  USE tf_coils
7  IMPLICIT NONE
8 !-----------------------------------------------
9 ! L o c a l V a r i a b l e s
10 !-----------------------------------------------
11  INTEGER :: i, n
12  INTEGER :: nvariables, modes
13  REAL(rprec) :: xvariables(*)
14 !-----------------------------------------------
15 
16 ! load the unique coil parameters with values from variables in
17 ! optimization
18 
19  nvariables = 0
20  n = 0
21 
22 ! Case with coils on both symmetry planes phi = 0 and phi = pi/nfp
23 ! (lsymm = F). No. of coils per field period must be even (nodd = 0).
24 
25  IF ((nodd.EQ.0) .AND. (.NOT.lsymm)) THEN
26 
27 ! Symmetry coil at phi = 0.
28  i = 1
29  phis(i,0) = 0
30  DO modes = 1, nf_phi
31  n = n + 1
32  phis(i,modes) = xvariables(n)
33  END DO
34 
35  rhos(i,0) = 0
36  DO modes = 1, nf_rho
37  n = n + 1
38  rhos(i,modes) = xvariables(n)
39  END DO
40 
41 ! Coils 2 through nmid - 1
42  DO i = 2, nmid-1
43  n = n + 1
44  phic(i,modes) = xvariables(n)
45  phis(i,0) = 0
46  DO modes = 1,nf_phi
47  n = n + 1
48  phic(i,modes) = xvariables(n)
49  n = n + 1
50  phis(i,modes) = xvariables(n)
51  END DO
52 
53  n = n + 1
54  rhoc(i,0) = xvariables(n)
55  rhos(i,0) = 0
56  DO modes = 1,nf_rho
57  n = n + 1
58  rhos(i,modes) = xvariables(n)
59  END DO
60  END DO
61 
62 ! Symmetry coil at phi = pi/nfp
63  i = nmid
64  phis(i,0) = 0
65  DO modes = 1, nf_phi
66  n = n + 1
67  phis(i,modes) = xvariables(n)
68  END DO
69 
70  rhos(i,0) = 0
71  DO modes = 1, nf_rho
72  n = n + 1
73  rhos(i,modes) = xvariables(n)
74  END DO
75 
76 ! Cases with a coil on phi = 0 (lsymm = T), or on phi = pi/nfp
77 ! (lsymm = F), but not both. There may be an even number of coils
78 ! per period (nodd = 0), or an odd number of coils per period
79 ! (nodd = 1).
80 
81  ELSE
82 
83  DO i = 1, nmid-nodd
84  n = n + 1
85  phic(i,0) = xvariables(n)
86  phis(i,0) = 0
87  DO modes = 1,nf_phi
88  n = n + 1
89  phic(i,modes) = xvariables(n)
90  n = n + 1
91  phis(i,modes) = xvariables(n)
92  END DO
93 
94  n = n + 1
95  rhoc(i,0) = xvariables(n)
96  rhos(i,0) = 0
97  DO modes = 1,nf_rho
98  n = n + 1
99  rhoc(i,modes) = xvariables(n)
100  n = n + 1
101  rhos(i,modes) = xvariables(n)
102  END DO
103  END DO
104  IF (nodd .EQ. 1) THEN
105  i = nmid
106  phis(i,0) = 0
107  DO modes = 1, nf_phi
108  n = n + 1
109  phis(i,modes) = xvariables(n)
110  END DO
111 
112  rhos(i,0) = 0
113  DO modes = 1, nf_rho
114  n = n + 1
115  rhos(i,modes) = xvariables(n)
116  END DO
117  END IF
118 
119  END IF
120 
121  nvariables = n
122 
123  END SUBROUTINE load_modular_coils