ETS  \$Id: Doxyfile 2162 2020-02-26 14:16:09Z g2dpc $
 All Classes Files Functions Variables Pages
controller.f
Go to the documentation of this file.
1  subroutine cntrlr_iter(kon_ini,kgrid,voltpf)
2 
3  include 'double.inc'
4  include 'parevo.inc'
5  include 'dimcp.inc'
6  parameter(nconp=ngapp+npfc0+1)
7  parameter(ntimp=1000)
8 
9  common /com_contr/ key_cont
10  common /com_cam/ camtok
11  common /com_cpdiv/ divgap(ngapp,ntimp),divpfc(npfc0,ntimp),
12  & vpfc(npfc0,ntimp),xtim(ntimp),velz(ntimp),
13  & placurr(ntimp),rm_t(ntimp),zm_t(ntimp),
14  & cam_tok(ntimp)
15  common /com_conpar/ r_ref,z_ref,tok_ref,dgap_ref,currpf_ref
16  dimension voltpf(*)
17  dimension currpf(npfc0),currpf_ref(npfc0)
18  dimension pf_turns(npfc0)
19  dimension dgap(ngapp),dgap_ref(ngapp)
20  dimension rcp(ngapp),zcp(ngapp)
21 
22 ! save R_ax,Z_ax,R_cc,Z_cc
23  real*8 r_ax,z_ax,r_cc,z_cc
24  !save R_ref,Z_ref,tok_ref
25  !save Dgap_ref,currpf_ref
26 ! save pf_turns
27  real*8 pf_turns
28 ! save i_en
29  integer i_en
30 
31  i_en=i_en+1
32 
33 !!!!!controllable variables:{gaps(1:6),Jpl,pfc(1:11)}
34 !
35  call get_tim(dt,time)
36  call get_rzcp(rcp,zcp,ngap)
37  if(kgrid.eq.0) then
38  call get_psix(r_xp,z_xp,psi_xp)
39  elseif(kgrid.eq.1) then
40  call get_fpsix(r_xp,z_xp,psi_xp)
41  endif
42 
43  do i=1,ngap
44  rg=rcp(i)
45  zg=zcp(i)
46  rt=rg
47  zt=zg
48  ut=psi_xp
49  if(kgrid.eq.0) then
50  call gap(ut,rt,zt,rg,zg)
51  !call gap(ut,rt,zt,rg,zg) !!!!!!!!for tcv vde !!!!!!!!!!!!!!!!!!
52  elseif(kgrid.eq.1) then
53  call f_gap(ut,rt,zt,rg,zg)
54  endif
55  gap_sign=dsign(1.d0,psi_xp-ut)
56  dgap(i)=dsqrt((rg-rt)**2+(zg-zt)**2)*gap_sign
57  !!!!!!!!for tcv vde!!!!!!!!!!!!!!!!!!Dgap(i)=0.
58  enddo
59 
60  z_ax_old=z_ax
61  r_ax_old=r_ax
62  z_cc_old=z_cc
63  r_cc_old=r_cc
64  call get_shape(r_cc,z_cc,r_ax,z_ax,platok)
65  call get_pfc(currpf,n_pf)
66 
67  vz_ax=(z_ax-z_ax_old)/dt
68  vz_cc=(z_cc-z_cc_old)/dt
69 !
70 !!!!!controllable variables
71 
72 
73 !!!!!reference variables:{gaps_ref(1:6),Jpl_ref,pfc_ref(1:11)}
74 !
75  !if(i_en.eq.1)then
76  if(kon_ini.eq.0)then
77  do i=1,ngap
78  dgap_ref(i)=dgap(i)
79  enddo
80  !Dgap_ref(3)=0.15d0
81 
82  do i=1,n_pf
83  currpf_ref(i)=currpf(i)
84  enddo
85 
86  tok_ref=platok
87  r_ref=r_ax
88  z_ref=z_ax
89 
90  vz_ax=0.d0
91  vz_cc=0.d0
92 !
93 !!!!!reference variables
94  do i=1,n_pf
95  voltpf(i)=0.d0
96  enddo
97 
98  go to 1000
99  endif
100  !go to 1000 !!!!!!!!for tcv vde!!!!!!!!!!!!!!!!!!
101 
102  !if(time.le.0.25d0) then
103  ! voltpf(7)= -10.d0 !!pf2
104  ! voltpf(8)= -10.d0 !!pf3
105  ! voltpf(9)= 10.d0 !!pf4
106  ! voltpf(10)= 10.d0 !!pf5
107  !endif
108  ! go to 1000 !temporary:vde
109 
110  call congap_m( ngap,dgap,dgap_ref,dt,time,
111  & n_pf,currpf,currpf_ref,
112  & platok,tok_ref,r_ax,z_ax,r_ref,z_ref,vz_cc,
113  & voltpf )
114 
115 
116  !call convert( dt,time,n_pf,Vz_cc,voltpf )
117  call convert_m( dt,time,n_pf,vz_cc,voltpf )
118  call volt_lim(voltpf,n_pf)
119 
120  1000 continue
121 
122  if(i_en.le.ntimp) then
123 
124  do i=1,ngap
125  divgap(i,i_en)=dgap(i)-dgap_ref(i) !
126  enddo
127 
128  do i=1,n_pf
129  divpfc(i,i_en)=currpf(i)-currpf_ref(i)
130  enddo
131 
132  do i=1,n_pf
133  vpfc(i,i_en)=voltpf(i)
134  enddo
135 
136  xtim(i_en)=time
137 
138  velz(i_en)=vz_cc
139  placurr(i_en)=platok-tok_ref !
140  rm_t(i_en)=r_ax
141  zm_t(i_en)=z_ax
142  cam_tok(i_en)=camtok
143 
144  endif
145 
146  if(i_en/5*5.eq.i_en) then
147  call wrd_cp(i_en,ngap,n_pf)
148  endif
149 
150 
151  return
152  end
153 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
154  subroutine congap( ngap,Dgap,Dgap_ref,dt,time,
155  & n_pf,currpf,currpf_ref,
156  & platok,tok_ref,r_ax,z_ax,r_ref,z_ref,vz_cc,
157  & voltpf )
158 
159  include 'double.inc'
160  parameter(nconp=20)
161 
162  dimension voltpf(*)
163  dimension currpf(*),currpf_ref(*)
164  dimension dgap(*),dgap_ref(*)
165 
166  dimension ac(nconp,nconp),bc(nconp,nconp)
167  dimension cc(nconp,nconp),dc(nconp,nconp)
168  dimension x(nconp),y(nconp),u(nconp),usat(nconp)
169  dimension xp(nconp)
170 ! save i_en
171  integer i_en
172 ! save Ac,Bc,Cc,Dc
173 ! save x
174  real*8 ac,bc,cc,dc
175  real*8 x
176 ! save nx,ny
177  integer nx,ny
178 
179  i_en=i_en+1
180 
181  if(i_en.eq.1) then
182 
183  write(fname,'(a,a)') path(1:kname),'ABCD.wr'
184  open(1,file=fname)
185  read(1,*) n,m
186  read(1,*) ((ac(i,j),i=1,n),j=1,m)
187  read(1,*) n,m
188  read(1,*) ((bc(i,j),i=1,n),j=1,m)
189  read(1,*) n,m
190  read(1,*) ((cc(i,j),i=1,n),j=1,m)
191  read(1,*) n,m
192  read(1,*) ((dc(i,j),i=1,n),j=1,m)
193  close(1)
194 
195  nx=n_pf
196  ny=m
197 
198  endif
199 
200  iy=0
201  do i=1,ngap
202  iy=iy+1
203  y(iy)=dgap(i)-dgap_ref(i) !
204  enddo
205  iy=iy+1
206  y(iy)=platok-tok_ref
207  do i=1,n_pf
208  iy=iy+1
209  y(iy)=currpf(i)-currpf_ref(i)
210  enddo
211 
212  do i=1,nx
213  ax=0.d0
214  by=0.d0
215  do j=1,nx
216  ax=ax+ac(i,j)*x(j)
217  enddo
218  do j=1,ny
219  by=by+bc(i,j)*y(j)
220  enddo
221  xp(i)=x(i)+dt*(ax+by)
222  enddo
223 
224  do i=1,nx
225  cx=0.d0
226  dy=0.d0
227  do j=1,nx
228  cx=cx+cc(i,j)*xp(j)
229  enddo
230  do j=1,ny
231  dy=dy+dc(i,j)*y(j)
232  enddo
233  u(i)=cx+dy
234  enddo
235 
236  do i=1,nx
237  x(i)=xp(i)
238  enddo
239 
240  do i=1,n_pf
241  voltpf(i)=u(i)
242  enddo
243 
244  return
245  end
246 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
247 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
248  subroutine congap_k( ngap,Dgap,Dgap_ref,dt,time,
249  & n_pf,currpf,currpf_ref,
250  & platok,tok_ref,r_ax,z_ax,r_ref,z_ref,vz_cc,
251  & voltpf )
252 
253  include 'double.inc'
254  parameter(nconp=20)
255 
256  dimension voltpf(*)
257  dimension currpf(*),currpf_ref(*)
258  dimension dgap(*),dgap_ref(*)
259 
260  dimension ac(nconp,nconp),bc(nconp,nconp)
261  dimension cc(nconp,nconp),dc(nconp,nconp)
262  dimension x(nconp),y(nconp),u(nconp),usat(nconp)
263  dimension xp(nconp)
264 ! save i_en
265 ! save Ac,Bc,Cc,Dc
266 ! save x
267 ! save nx,ny
268 ! save t_delay,k_delay
269  integer i_en
270  real*8 ac,bc,cc,dc
271  real*8 x
272  integer nx,ny
273  real*8 t_delay,k_delay
274 
275  t_delay=165.d-3
276  k_delay=t_delay/dt
277 
278  i_en=i_en+1
279 
280  if(i_en.eq.1) then
281 
282  write(fname,'(a,a)') path(1:kname),'ahatmat'
283  open(1,file=fname)
284  !read(1,*) n,m
285  n=11
286  m=11
287  read(1,*) ((ac(i,j),j=1,m),i=1,n)
288  close(1)
289 
290  write(fname,'(a,a)') path(1:kname),'bhatmat'
291  open(1,file=fname)
292  !read(1,*) n,m
293  n=11
294  m=18
295  read(1,*) ((bc(i,j),j=1,m),i=1,n)
296  close(1)
297 
298  write(fname,'(a,a)') path(1:kname),'chatmat'
299  open(1,file=fname)
300  !read(1,*) n,m
301  n=11
302  m=11
303  read(1,*) ((cc(i,j),j=1,m),i=1,n)
304  close(1)
305 
306  write(fname,'(a,a)') path(1:kname),'dhatmat'
307  open(1,file=fname)
308  !read(1,*) n,m
309  n=11
310  m=18
311  read(1,*) ((dc(i,j),j=1,m),i=1,n)
312  close(1)
313 
314  nx=n_pf
315  ny=m
316 
317  endif
318 
319  iy=0
320  do i=1,ngap
321  iy=iy+1
322  y(iy)=dgap(i) !-Dgap_ref(i)
323  enddo
324  iy=iy+1
325  y(iy)=platok-tok_ref
326  do i=1,n_pf
327  iy=iy+1
328  y(iy)=currpf(i)-currpf_ref(i)
329  enddo
330 
331  do i=1,nx
332  ax=0.d0
333  by=0.d0
334  do j=1,nx
335  ax=ax+ac(i,j)*x(j)
336  enddo
337  do j=1,ny
338  by=by+bc(i,j)*y(j)
339  enddo
340  xp(i)=x(i)+dt*(ax+by)
341  enddo
342 
343  do i=1,nx
344  cx=0.d0
345  dy=0.d0
346  do j=1,nx
347  cx=cx+cc(i,j)*xp(j)
348  enddo
349  do j=1,ny
350  dy=dy+dc(i,j)*y(j)
351  enddo
352  u(i)=cx+dy
353  enddo
354 
355  do i=1,nx
356  x(i)=xp(i)
357  enddo
358 
359  if((i_en-1)/k_delay*k_delay.eq.i_en-1) then
360  do i=1,n_pf
361  voltpf(i)=u(i)
362  enddo
363  endif
364 
365  return
366  end
367 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
368  subroutine congap_m( ngap,Dgap,Dgap_ref,dt,time,
369  & n_pf,currpf,currpf_ref,
370  & platok,tok_ref,r_ax,z_ax,r_ref,z_ref,vz_cc,
371  & voltpf )
372 
373  include 'double.inc'
374  parameter(nconp=20)
375 
376  dimension voltpf(*)
377  dimension currpf(*),currpf_ref(*)
378  dimension dgap(*),dgap_ref(*)
379 
380  dimension ac(nconp,nconp),bc(nconp,nconp)
381  dimension cc(nconp,nconp),dc(nconp,nconp)
382  dimension x(nconp),y(nconp),u(nconp),uk(nconp),usat(nconp)
383  dimension xp(nconp)
384 ! save i_en
385 ! save Ac,Bc,Cc,Dc
386 ! save x
387 ! save nx,ny
388  integer i_en
389  real*8 ac,bc,cc,dc
390  real*8 x
391  integer nx,ny
392 
393  tau=2.d-2
394  i_en=i_en+1
395 
396  if(i_en.eq.1) then
397 
398  write(fname,'(a,a)') path(1:kname),'ABCD_m.wr'
399  open(1,file=fname)
400  !open(2,file='ABCD_mf.wr')
401  read(1,*) n,m
402  nx=n
403  read(1,*) ((ac(i,j),i=1,n),j=1,m)
404 
405  !write(2,*) n,m
406  !write(2,*) ((Ac(i,j),i=1,n),j=1,m)
407 
408  read(1,*) n,m
409  ny=m
410  read(1,*) ((bc(i,j),i=1,n),j=1,m)
411 
412  !write(2,*) n,m
413  !write(2,*) ((Bc(i,j),i=1,n),j=1,m)
414 
415  read(1,*) n,m
416  read(1,*) ((cc(i,j),i=1,n),j=1,m)
417 
418  !write(2,*) n,m
419  !write(2,*) ((Cc(i,j),i=1,n),j=1,m)
420 
421  read(1,*) n,m
422  read(1,*) ((dc(i,j),i=1,n),j=1,m)
423 
424  !write(2,*) n,m
425  !write(2,*) ((Dc(i,j),i=1,n),j=1,m)
426  !close(2)
427  close(1)
428 
429  !pause 'pause:abcd '
430  endif
431 
432  iy=0
433  do i=1,ngap
434  iy=iy+1
435  y(iy)=dgap(i)-dgap_ref(i)
436  enddo
437  iy=iy+1
438  y(iy)=platok-tok_ref
439 
440  do i=1,6
441  iy=iy+1
442  y(iy)=currpf(i+5)-currpf_ref(i+5) !pf(1:6)
443  enddo
444 
445  iy=iy+1
446  y(iy)=currpf(5)-currpf_ref(5) !CS3L
447  iy=iy+1
448  y(iy)=currpf(3)-currpf_ref(3) !CS2L
449  iy=iy+1
450  y(iy)=currpf(1)-currpf_ref(1) !CS1
451  iy=iy+1
452  y(iy)=currpf(2)-currpf_ref(2) !CS2U
453  iy=iy+1
454  y(iy)=currpf(4)-currpf_ref(4) !CS3U
455 
456  do i=1,nx
457  ax=0.d0
458  by=0.d0
459  do j=1,nx
460  ax=ax+ac(i,j)*x(j)
461  enddo
462  do j=1,ny
463  by=by+bc(i,j)*y(j)
464  enddo
465  xp(i)=x(i)+tau*(ax+by)
466  enddo
467 
468  do i=1,n_pf
469  cx=0.d0
470  dy=0.d0
471  do j=1,nx
472  cx=cx+cc(i,j)*xp(j)
473  enddo
474  do j=1,ny
475  dy=dy+dc(i,j)*y(j)
476  enddo
477  uk(i)=cx+dy
478  enddo
479 
480  do i=1,nx
481  x(i)=xp(i)
482  enddo
483 
484  do i=1,6
485  u(i+5)=uk(i) ! pf1:pf6
486  enddo
487  u(5)=uk(7) !CS3L
488  u(3)=uk(8) !CS2L
489  u(1)=uk(9) !CS1
490  u(2)=uk(10) !CS2U
491  u(4)=uk(11) !CS3U
492 
493  do i=1,n_pf
494  voltpf(i)=u(i)
495  enddo
496 
497  return
498  end
499 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
500  subroutine convert( dt,time,n_pf,Vz_cc,voltpf )
501 
502  include 'double.inc'
503  parameter(nconp=20)
504 
505  dimension voltpf(*)
506 
507  dimension acc(nconp,nconp),bcc(nconp,nconp)
508  dimension ccc(nconp,nconp),dcc(nconp,nconp)
509  dimension x(nconp),y(nconp),u(nconp),usat(nconp)
510  dimension xp(nconp)
511 ! save i_en
512 ! save Acc,Bcc,Ccc,Dcc
513 ! save x
514 ! save nx,ny
515  integer i_en
516  real*8 acc,bcc,ccc,dcc
517  real*8 x
518  integer nx,ny
519 
520  i_en=i_en+1
521 
522  if(i_en.eq.1) then
523 
524  write(fname,'(a,a)') path(1:kname),'ABCDz.wr'
525  open(1,file=fname)
526  read(1,*) n,m
527  read(1,*) ((acc(i,j),i=1,n),j=1,m) ![4x4]
528  read(1,*) n,m
529  read(1,*) ((bcc(i,j),i=1,n),j=1,m) ![4x1]
530  read(1,*) n,m
531  read(1,*) ((ccc(i,j),i=1,n),j=1,m) ![1x4]
532  read(1,*) n,m
533  read(1,*) ((dcc(i,j),i=1,n),j=1,m) ![1x1]
534  close(1)
535 
536  nx=4
537  ny=1
538  vz_cc=0.d0
539 
540  endif
541 
542  do i=1,ny
543  y(i)=vz_cc
544  enddo
545 
546  do i=1,nx
547  ax=0.d0
548  by=0.d0
549  do j=1,nx
550  ax=ax+acc(i,j)*x(j)
551  enddo
552  do j=1,ny
553  by=by+bcc(i,j)*y(j)
554  enddo
555  xp(i)=x(i)+dt*(ax+by)
556  enddo
557 
558  do i=1,nx
559  cx=0.d0
560  dy=0.d0
561  do j=1,nx
562  cx=cx+ccc(j,i)*xp(j)
563  enddo
564  do j=1,ny
565  dy=dy+dcc(i,j)*y(j)
566  enddo
567  u(i)=cx+dy
568  enddo
569 
570  do i=1,nx
571  x(i)=xp(i)
572  enddo
573 
574  voltpf(7)=voltpf(7)-u(1) /106.d0 !!pf2
575  voltpf(8)=voltpf(8)-u(1) /185.d0 !!pf3
576  voltpf(9)=voltpf(9)+u(1) /169.d0 !!pf4
577  voltpf(10)=voltpf(10)+u(1) /217.d0 !!pf5
578 
579  return
580  end
581 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
582 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
583  subroutine convert_m( dt,time,n_pf,Vz_cc,voltpf )
584 
585  include 'double.inc'
586  parameter(nconp=20)
587 
588  dimension voltpf(*)
589  dimension pf_turns(40)
590 
591  dimension acc(nconp,nconp),bcc(nconp,nconp)
592  dimension ccc(nconp,nconp),dcc(nconp,nconp)
593  dimension x(nconp),y(nconp),u(nconp),usat(nconp)
594  dimension xp(nconp)
595 ! save i_en
596 ! save Acc,Bcc,Ccc,Dcc
597 ! save x
598 ! save nx,ny
599  integer i_en
600  real*8 acc,bcc,ccc,dcc
601  real*8 x
602  integer nx,ny
603 
604  tau=2.d-2
605 
606  i_en=i_en+1
607 
608  if(i_en.eq.1) then
609 
610  write(fname,'(a,a)') path(1:kname),'ABCDz_m.wr'
611  open(1,file=fname)
612  read(1,*) n,m
613  read(1,*) ((acc(i,j),i=1,n),j=1,m) ![4x4]
614  read(1,*) n,m
615  read(1,*) ((bcc(i,j),i=1,n),j=1,m) ![4x1]
616  read(1,*) n,m
617  read(1,*) ((ccc(i,j),i=1,n),j=1,m) ![11x4]
618  read(1,*) n,m
619  read(1,*) ((dcc(i,j),i=1,n),j=1,m) ![11x1]
620  close(1)
621 
622  nx=4
623  ny=1
624  vz_cc=0.d0
625 
626  do i=7,12
627  pf_turns(i)=548.d0
628  enddo
629  pf_turns(1)=249.d0
630  pf_turns(2)=106.d0
631  pf_turns(3)=185.d0
632  pf_turns(4)=169.d0
633  pf_turns(5)=217.d0
634  pf_turns(6)=425.d0
635 
636  endif
637 
638  do i=1,ny
639  y(i)=vz_cc
640  enddo
641 
642  do i=1,nx
643  ax=0.d0
644  by=0.d0
645  do j=1,nx
646  ax=ax+acc(i,j)*x(j)
647  enddo
648  do j=1,ny
649  by=by+bcc(i,j)*y(j)
650  enddo
651  xp(i)=x(i)+tau*(ax+by)
652  enddo
653 
654  do i=1,n_pf
655  cx=0.d0
656  dy=0.d0
657  do j=1,nx
658  cx=cx+ccc(i,j)*xp(j)
659  enddo
660  do j=1,ny
661  dy=dy+dcc(i,j)*y(j)
662  enddo
663  u(i)=cx+dy
664  enddo
665 
666  do i=1,nx
667  x(i)=xp(i)
668  enddo
669 
670  do i=1,6
671  voltpf(i+5)=voltpf(i+5)+u(i) ! pf1:pf6
672  enddo
673  voltpf(5)=voltpf(5)+u(7) !CS3L
674  voltpf(3)=voltpf(3)+u(8) !CS2L
675  voltpf(1)=voltpf(1)+u(9) !CS1
676  voltpf(2)=voltpf(2)+u(10) !CS2U
677  voltpf(4)=voltpf(4)+u(11) !CS3U
678 
679 !a. vPF2 = vPF2shape – vZ/106.
680 !b. vPF3 = vPF3shape – vZ/185.
681 !c. vPF4 = vPF4shape + vZ/169.
682 !d. vPF5 = vPF5shape + vZ/217.
683 
684  return
685  end
686 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
687 
688 ! subroutine cntrlr_iter_m(voltpf)
689 !
690 ! include 'double.inc'
691 ! include 'parevo.inc'
692 ! parameter(ngapp=10)
693 ! parameter(nconp=ngapp+npfc0+1)
694 !
695 ! dimension voltpf(*)
696 ! dimension currpf(npfc0),currpf_ref(npfc0)
697 ! dimension Dgap(ngapp),Dgap_ref(ngapp)
698 ! dimension Rcp(ngapp),Zcp(ngapp)
699 !
700 ! save R_ax,Z_ax,R_cc,Z_cc
701 !
702 !!!!!!!!!!!!!!!DINA variables!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
703 !!
704 ! dimension vchopper(npfc0),u_1(npfc0),u_kd(npfc0),u_help(npfc0)
705 ! dimension zvconverter(npfc0)
706 ! dimension pf(npfc0),curr_ref_p(npfc0)
707 ! dimension gaps(ngapp),gaps_ref_p(ngapp)
708 ! dimension error(nconp)
709 ! dimension zvresist(npfc0)
710 ! dimension pf_turns(npfc0)
711 ! dimension pf_lim(npfc0)
712 ! dimension state_vert(nconp),state_old_vert(nconp)
713 ! dimension state(nconp),state_old(nconp)
714 ! save i_en
715 ! save curr_ref_p,gaps_ref_p
716 ! save R_ref,Z_ref,cip1,rmag,zmag
717 ! save state_vert,state_old_vert
718 ! save state,state_old
719 ! save pf_lim,pf_turns,zvresist
720 ! save zvconverter,u_1,u_kd,u_help,vchopper
721 ! save error
722 ! i_en=i_en+1
723 !!
724 !!!!!!!!!!!!!!!DINA variables!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
725 !
726 !
727 !!!!!!controllable variables:{gaps(1:6),Jpl,pfc(1:11)}
728 !
729 ! call get_tim(dt,time)
730 ! call get_RZcp(Rcp,Zcp,ngap)
731 ! call get_psix(r_xp,z_xp,psi_xp)
732 !
733 ! do i=1,ngap
734 ! rg=Rcp(i)
735 ! zg=Zcp(i)
736 ! rt=rg
737 ! zt=zg
738 ! ut=psi_xp
739 ! call gap(ut,rt,zt,rg,zg)
740 ! Dgap(i)=dsqrt((rg-rt)**2+(zg-zt)**2)
741 ! enddo
742 !
743 ! Z_ax_old=Z_ax
744 ! R_ax_old=R_ax
745 ! Z_cc_old=Z_cc
746 ! R_cc_old=R_cc
747 ! call get_shape(R_cc,Z_cc,R_ax,Z_ax,platok)
748 ! call get_pfc(currpf,n_pf)
749 !
750 ! Vz_ax=(Z_ax-Z_ax_old)/dt
751 ! Vz_cc=(Z_cc-Z_cc_old)/dt
752 !
753 !
754 !!!!!!controllable variables
755 !
756 !!!!!!transformation to DINA variables format:
757 
758 !c vchopper(i) output voltage to PF coils
759 !c gaps are gaps in time a
760 !c zvel - velocity
761 !c rref nd zref are R and Z reference positions
762 !c tpl plasma current
763 !c cip1 reference value for plams current
764 !c npf number of PF coils
765 !c pf coils currents
766 !c rmag,zmag - Magnetic axes coordinates
767 !c elong - elongation
768 !c r_cur,z_cur are current cenroid coorinates
769 !
770 ! npf=n_pf+1
771 ! klim=1
772 ! kpr=1
773 ! tpl=platok*1.d3
774 ! rmag=R_ax*1.d2
775 ! zmag=Z_ax*1.d2
776 ! r_cur=R_cc*1.d2
777 ! z_cur=Z_cc*1.d2
778 ! tt=time*1.d3
779 ! zvel=Vz_cc*1.d-1
780 !
781 ! do i=1,ngap
782 ! gaps(i)=Dgap(i)*1.d2
783 ! enddo
784 !
785 ! do i=1,6
786 ! pf(i)=currpf(i+5)*1.d3
787 ! enddo
788 ! pf(7)=currpf(5)*1.d3 !CS3L
789 ! pf(8)=currpf(3)*1.d3 !CS2L
790 ! pf(9)=currpf(1)*1.d3 !CS1L
791 ! pf(10)=currpf(1)*1.d3 !CS1U
792 ! pf(11)=currpf(2)*1.d3 !CS2U
793 ! pf(12)=currpf(4)*1.d3 !CS3U
794 !
795 ! do i=7,12
796 ! pf_turns(i)=548.d0
797 ! enddo
798 ! pf_turns(1)=249.d0
799 ! pf_turns(2)=106.d0
800 ! pf_turns(3)=185.d0
801 ! pf_turns(4)=169.d0
802 ! pf_turns(5)=217.d0
803 ! pf_turns(6)=425.d0
804 !
805 ! if(i_en.eq.1)then
806 ! rref=rmag
807 ! zref=zmag
808 ! cip1=tpl
809 ! do i=1,npf
810 ! curr_ref_p(i)=pf(i)
811 ! enddo
812 ! do i=1,ngap
813 ! gaps_ref_p(i)=gaps(i)
814 ! enddo
815 ! gaps_ref_p(3)=7.d0 !
816 ! zvel=0.d0
817 ! endif
818 !
819 !
820 !
821 ! call SCEN_CONTROL_c(
822 ! & tpl,cip1,zref,rref,
823 ! & npf,vchopper,r_cur,z_cur,
824 ! & u_1,u_kd,error,zvel,elong,tt,gaps,gaps_ref_p,
825 ! & pf,curr_ref_p,klim,
826 ! & state,state_old,pf_turns,zvconverter,zvresist,
827 ! & u_help,state_vert,state_old_vert,rmag,zmag,pf_lim,kpr)
828 !
829 ! do i=1,6
830 ! voltpf(i+5)=vchopper(i)
831 ! enddo
832 ! voltpf(5)=vchopper(7) !CS3L
833 ! voltpf(3)=vchopper(8) !CS2L
834 ! voltpf(1)=vchopper(9) !CS1L
835 ! voltpf(1)=vchopper(10) !CS1U
836 ! voltpf(2)=vchopper(11) !CS2U
837 ! voltpf(4)=vchopper(12) !CS3U
838 !
839 !
840 ! if(i_en.eq.1)then
841 ! do i=1,n_pf
842 ! voltpf(i)=0.d0
843 ! enddo
844 ! endif
845 !
846 ! return
847 ! end
848 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
849  !subroutine get_RZcp_m(Rcp,Zcp,ngap)
850  subroutine get_rzcp(Rcp,Zcp,ngap)
851 
852  include 'double.inc'
853  dimension rcp(*),zcp(*)
854 
855  ngap=6
856 
857  rcp(1)=4.344
858  rcp(2)=5.575
859  rcp(3)=8.2806
860  rcp(4)=7.5095
861  rcp(5)=5.3315
862  rcp(6)=4.0599
863 
864  zcp(1)=-3.458
865  zcp(2)=-3.891
866  zcp(3)= 0.4665
867  zcp(4)= 2.9971
868  zcp(5)= 4.5804
869  zcp(6)= 0.7777
870 
871  return
872  end
873 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
874  !subroutine get_RZcp(Rcp,Zcp,ngap)
875  subroutine get_rzcp_k(Rcp,Zcp,ngap)
876 
877  include 'double.inc'
878  dimension rcp(*),zcp(*)
879 
880  ngap=6
881 
882  rcp(1)=4.200
883  rcp(2)=5.600
884  rcp(3)=8.200
885  rcp(4)=7.170
886  rcp(5)=5.420
887  rcp(6)=4.200
888 
889  zcp(1)=-3.800
890  zcp(2)=-4.500
891  zcp(3)=0.420
892  zcp(4)=3.050
893  zcp(5)=4.050
894  zcp(6)=1.000
895 
896  return
897  end
898 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
899  subroutine get_shape(R_cc,Z_cc,R_ax,Z_ax, platok)
900 
901  include 'double.inc'
902  include 'dim.inc'
903  include 'compol.inc'
904 
905  r_ax=rm
906  z_ax=zm
907 
908  platok=tokp
909 
910  rmax=rm
911  zmax=zm
912  rmin=rm
913  zmin=zm
914 
915  do j=2,nt1
916  rmax=dmax1(rmax,r(iplas,j))
917  zmax=dmax1(zmax,z(iplas,j))
918  rmin=dmin1(rmin,r(iplas,j))
919  zmin=dmin1(zmin,z(iplas,j))
920  enddo
921 
922  r_cc=0.5d0*(rmax+rmin)
923  z_cc=0.5d0*(zmax+zmin)
924 
925  return
926  end
927 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
928  subroutine get_pfc(currpf,npf)
929 
930  include 'double.inc'
931  include 'prm.inc'
932  include 'comevl.inc'
933  common/comst1/ pjk(njlim),pjkp1(njlim),pjkp(njlim),pjkd(njlim)
934  dimension currpf(*)
935 
936  npf=nequi
937 
938  do i=1,nequi
939  currpf(i) = pjk(i)
940  enddo
941 
942  return
943  end
944 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
945  subroutine volt_lim(voltpf,npf)
946 
947  include 'double.inc'
948  include 'parevo.inc'
949  !dimension voltpf(*)
950  dimension voltpf(npfc0)
951  dimension usat(npfc0)
952 
953  usat(1)=2.7d0
954  usat(2)=2.7d0
955  usat(3)=2.7d0
956  usat(4)=2.7d0
957  usat(5)=2.7d0
958  usat(6)=6.0d0
959  usat(7)=53.8d0
960  usat(8)=30.8d0
961  usat(9)=33.7d0
962  usat(10)=26.3d0
963  usat(11)=3.5d0
964 
965  do i=1,npf
966  if(dabs(voltpf(i)).gt.usat(i)) then
967  voltpf(i)=dsign(usat(i),voltpf(i))
968  endif
969  enddo
970 
971 !a. vCS1 = +/- 2.7 V/t,
972 !b. vCS2U = +/- 2.7 V/t,
973 !c. vCS2L = +/- 2.7 V/t,
974 !d. vCS3U = +/- 2.7 V/t,
975 !e. vCS3L = +/- 2.7 V/t,
976 !f. vPF1 = +/- 6.0 V/t,
977 !g. vPF2 = +/-53.8 V/t,,
978 !h. vPF3 = +/- 30.8 V/t,
979 !i. vPF4 = +/- 33.7 V/t,
980 !j. vPF5 = +/- 26.3 V/t,
981 !k. vPF6 = +/- 3.5 V/t.
982 
983  return
984  end
985 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
986  subroutine wrd_cp(i_en,ngap,npf)
987 
988  include 'double.inc'
989  parameter(ngapp=10)
990  parameter(ntimp=1000)
991  include 'parevo.inc'
992  common /com_cam/ camtok
993  common /com_cpdiv/ divgap(ngapp,ntimp),divpfc(npfc0,ntimp),
994  & vpfc(npfc0,ntimp),xtim(ntimp),velz(ntimp),
995  & placurr(ntimp),rm_t(ntimp),zm_t(ntimp),
996  & cam_tok(ntimp)
997 
998  open(1,file='contim.wr')
999  write(1,*) i_en,ngap,npf
1000  write(1,*) ((divgap(i,j),i=1,ngap),j=1,i_en)
1001  write(1,*) ((divpfc(i,j),i=1,npf),j=1,i_en)
1002  write(1,*) ((vpfc(i,j),i=1,npf),j=1,i_en)
1003  write(1,*) (xtim(j),j=1,i_en)
1004  write(1,*) (velz(j),j=1,i_en)
1005  write(1,*) (placurr(j),j=1,i_en)
1006  write(1,*) (rm_t(j),j=1,i_en)
1007  write(1,*) (zm_t(j),j=1,i_en)
1008  write(1,*) (cam_tok(j),j=1,i_en)
1009  close(1)
1010 
1011  return
1012  end
1013 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1014  subroutine get_conp(R_ref,Z_ref,tok_ref,Dgap_ref,currpf_ref)
1015  include 'double.inc'
1016  include 'parevo.inc'
1017  include 'dimcp.inc'
1018  common /com_conpar/ rc_ref,zc_ref,cur_ref,gap_ref,pf_ref
1019  dimension pf_ref(npfc0),currpf_ref(*)
1020  dimension dgap_ref(*),gap_ref(ngapp)
1021 
1022  r_ref=rc_ref
1023  z_ref=zc_ref
1024  tok_ref=cur_ref
1025 
1026  do i=1,npfc0
1027  currpf_ref(i)=pf_ref(i)
1028  enddo
1029 
1030  do i=1,ngapp
1031  dgap_ref(i)=gap_ref(i)
1032  enddo
1033 
1034  return
1035  end
1036 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1037  subroutine put_conp(R_ref,Z_ref,tok_ref,Dgap_ref,currpf_ref)
1038  include 'double.inc'
1039  include 'parevo.inc'
1040  include 'dimcp.inc'
1041  common /com_conpar/ rc_ref,zc_ref,cur_ref,gap_ref,pf_ref
1042  dimension pf_ref(npfc0),currpf_ref(*)
1043  dimension dgap_ref(*),gap_ref(ngapp)
1044 
1045  rc_ref=r_ref
1046  zc_ref=z_ref
1047  cur_ref=tok_ref
1048 
1049  do i=1,npfc0
1050  pf_ref(i)=currpf_ref(i)
1051  enddo
1052 
1053  do i=1,ngapp
1054  gap_ref(i)=dgap_ref(i)
1055  enddo
1056 
1057  return
1058  end
1059 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1060 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1061  subroutine put_key_con(k)
1062  include 'iopath.inc'
1063  common /com_contr/ key_cont
1064  integer k
1065  key_cont=k
1066  return
1067  end
subroutine get_psix(r_xp, z_xp, psi_xp)
Definition: Spider_call.f:168
Module converts to/from CPOs to ETS types.
Definition: convert.f90:8
subroutine cntrlr_iter(kon_ini, kgrid, voltpf)
Definition: controller.f:1
subroutine get_tim(dt, time)
Definition: B_eqb.f:955
subroutine congap(ngap, Dgap, Dgap_ref, dt, time,
Definition: controller.f:154
subroutine congap_m(ngap, Dgap, Dgap_ref, dt, time,
Definition: controller.f:368
subroutine get_conp(R_ref, Z_ref, tok_ref, Dgap_ref, currpf_ref)
Definition: controller.f:1014
subroutine gap(ut, rt, zt, rg, zg)
Definition: Eq2_m.f:624
subroutine f_gap(ut, rt, zt, rg, zg)
Definition: Eq2_m.f:798
subroutine wrd_cp(i_en, ngap, npf)
Definition: controller.f:986
subroutine get_fpsix(r_xp, z_xp, psi_xp)
Definition: Spider_call.f:182
subroutine put_key_con(k)
Definition: controller.f:1061
subroutine get_rzcp(Rcp, Zcp, ngap)
Definition: controller.f:850
subroutine volt_lim(voltpf, npf)
Definition: controller.f:945
subroutine congap_k(ngap, Dgap, Dgap_ref, dt, time,
Definition: controller.f:248
subroutine get_pfc(currpf, npf)
Definition: controller.f:928
subroutine put_conp(R_ref, Z_ref, tok_ref, Dgap_ref, currpf_ref)
Definition: controller.f:1037
subroutine convert_m(dt, time, n_pf, Vz_cc, voltpf)
Definition: controller.f:583
subroutine get_shape(R_cc, Z_cc, R_ax, Z_ax, platok)
Definition: controller.f:899
subroutine get_rzcp_k(Rcp, Zcp, ngap)
Definition: controller.f:875