ISCRUNCH ======== A program to compute the moment (Fourier) expansion of a parametric two-dimensional grid representation. The moment expansion is computed at some critical surfaces, in general the first (non-singular) and last, and then interpolated across the grid. A constrained variational principle is applied to determine numerically the optimal parametric angle that minimizes the width of the power spectrum. at the first non-singular and last radial surface. Input data are two rank-one grid arrays (xin1d, yin1d) of size nt*ns, where nt is the number of poloidal points and ns the number of radial surfaces. Indices first iterate over the poloidal nodes and then over the radial surfaces: e.g. xin1d(k), k=(j-1)*nt + i, represents the "x" points at the i-th poloidal node and j-th radial surface. Output data are the COS and SIN radially dependent coefficients of "x" and "y". Date: April 1 1999/Dec 19 2001 o KEYWORDS Moment, Fourier, parametric representation, minimization of the power spectrum width. o LANGUAGE f90 o PRECISION 8-byte reals and default (4 or 8 byte) integers o PREREQUISITE Blas and lapack libraries. o PLATFORM/OS Tested on alpha/OSF1, Solaris 2, Linux (f90/f95 by NAG) o CONTACT A. Pletzer (pletzer@pppl.gov) o AUTHORS S. P. Hirshman, R. Wieland, D. McCune. This portable and dynamically allocatable version by Alex Pletzer. o REFERENCES S. P. Hirshman and H K Meier, Phys Fluids 28, 1387 (1985) o USAGE real*8, dimension(:), allocatable :: xin1d ! x grid coordinates real*8, dimension(:), allocatable :: yin1d ! y grid coordinates integer nt, ns ! poloidal and radial ! grid sizes real*8, dimension(:), allocatable :: xmc1d ! COS coefficients of x real*8, dimension(:), allocatable :: xms1d ! SIN coefficients of x real*8, dimension(:), allocatable :: ymc1d ! COS coefficients of y real*8, dimension(:), allocatable :: yms1d ! SIN coefficients of y integer ic1 ! index of first ! (non-singular) surface integer inc ! index of last surface integer imom ! 0:imom Fourier modes integer ier ! = 0 if successful integer imom1 ! imom1 = imom+1 modes allocate( xin1d(nt*ns), yin1d(nt*ns) ) allocate(xmc1d(imom1*ns), xms1d(imom1*ns)) allocate(ymc1d(imom1*ns), yms1d(imom1*ns)) CALL scriscrunch(xin1d, yin1d, nt, ns, & xmc1d, xms1d, ymc1d, yms1d, & ic1,inc,imom,ier) o INPUT/OUTPUT FILES None o BUGS/PROBLEMS/LIMITATIONS Unknown. o TEST PROGRAM AND REFERENCE OUTPUT INPUT GRID (2nd and last surface) XIN1D(2nd) YIN1D(2nd) XIN1D(last) YIN1D(last) 1.087324 -0.057063 0.723762 -0.570634 1.090799 -0.058937 0.736473 -0.589372 1.094438 -0.059882 0.754061 -0.598816 1.098190 -0.059882 0.777532 -0.598816 1.101998 -0.058937 0.807755 -0.589372 1.105797 -0.057063 0.845298 -0.570634 1.109523 -0.054290 0.890252 -0.542896 1.113105 -0.050660 0.942044 -0.506597 1.116475 -0.046231 0.999307 -0.462308 1.119563 -0.041073 1.059813 -0.410728 1.122304 -0.035267 1.120537 -0.352671 1.124638 -0.028905 1.177848 -0.289052 1.126512 -0.022087 1.227840 -0.220875 1.127883 -0.014921 1.266767 -0.149214 1.128719 -0.007520 1.291511 -0.075200 1.129000 0.000000 1.300000 0.000000 1.128719 0.007520 1.291511 0.075200 1.127883 0.014921 1.266768 0.149214 1.126512 0.022087 1.227840 0.220875 1.124638 0.028905 1.177848 0.289052 1.122304 0.035267 1.120537 0.352671 1.119563 0.041073 1.059813 0.410728 1.116475 0.046231 0.999307 0.462308 1.113105 0.050660 0.942044 0.506597 1.109523 0.054290 0.890252 0.542896 1.105797 0.057063 0.845298 0.570634 1.101998 0.058937 0.807755 0.589372 1.098190 0.059882 0.777532 0.598816 1.094438 0.059882 0.754061 0.598816 1.090799 0.058937 0.736473 0.589372 1.087324 0.057063 0.723762 0.570634 1.084061 0.054290 0.714913 0.542896 1.081049 0.050660 0.708989 0.506597 1.078322 0.046231 0.705185 0.462308 1.075908 0.041073 0.702848 0.410728 1.073831 0.035267 0.701478 0.352671 1.072109 0.028905 0.700715 0.289052 1.070756 0.022087 0.700313 0.220875 1.069783 0.014921 0.700113 0.149214 1.069196 0.007520 0.700025 0.075200 1.069000 0.000000 0.700000 0.000000 1.069196 -0.007520 0.700025 -0.075200 1.069783 -0.014921 0.700113 -0.149214 1.070756 -0.022087 0.700313 -0.220875 1.072109 -0.028905 0.700715 -0.289052 1.073831 -0.035267 0.701478 -0.352671 1.075908 -0.041073 0.702848 -0.410728 1.078322 -0.046231 0.705185 -0.462308 1.081049 -0.050660 0.708989 -0.506597 1.084061 -0.054290 0.714913 -0.542896 1.087324 -0.057063 0.723762 -0.570634 ORDERING SURFACE POINTS Average elongation = 2.03467450191600 ITERATIONS RMS ERROR FORCE GRADIENT m #'s <= ON Fitting toroidal plane # 1 1 4.642E-03 4.252E-03 4.94 15 100 6.011E-04 4.363E-03 3.30 15 200 2.538E-04 9.449E-04 2.21 15 300 1.269E-04 3.734E-04 1.84 15 400 5.533E-05 1.689E-04 1.74 15 500 6.729E-05 8.061E-05 1.75 15 600 8.024E-05 4.068E-05 1.77 15 700 7.846E-05 3.229E-05 1.77 15 800 7.472E-05 3.127E-05 1.76 15 900 7.765E-05 3.578E-05 1.75 15 1000 8.573E-05 4.332E-05 1.72 15 1100 9.285E-05 5.532E-05 1.68 15 1200 9.721E-05 7.132E-05 1.63 15 1300 1.012E-04 9.310E-05 1.57 15 1400 1.047E-04 1.231E-04 1.48 15 1500 1.034E-04 1.609E-04 1.36 15 COMPUTATIONAL TIME = 7.031E-01 SECONDS ANGLE CONSTRAINTS WERE APPLIED BASED ON RM**2 + ZM**2 SPECTRUM WITH P = 4.00 AND Q = 1.00 c mb nb RmncB RmnsB ZmncB ZmnsB 0 0 1.0976E+00 0.0000E+00 -1.4692E-03 0.0000E+00 1 0 2.9696E-02 3.8535E-04 3.8535E-04 6.0462E-02 2 0 1.5708E-03 8.6426E-04 -1.2845E-03 -1.5950E-04 3 0 3.1086E-04 -3.1437E-04 2.6114E-04 4.3411E-04 4 0 -2.0481E-04 -1.2084E-04 2.1752E-04 -1.2728E-04 5 0 -1.9379E-05 1.6431E-04 -1.2902E-04 -9.6458E-05 6 0 1.0558E-04 -1.8459E-05 -4.4981E-05 8.5913E-05 7 0 -3.7015E-05 -6.8024E-05 6.6386E-05 1.5090E-05 8 0 -3.8564E-05 4.0723E-05 -6.8322E-07 -4.5890E-05 9 0 3.8545E-05 1.7779E-05 -3.2849E-05 8.8734E-06 10 0 5.0209E-06 -3.2112E-05 1.3075E-05 2.0914E-05 11 0 -2.5517E-05 4.4920E-06 1.2783E-05 -1.3818E-05 12 0 7.4195E-06 1.7494E-05 -1.3589E-05 -5.5783E-06 13 0 1.1805E-05 -1.0225E-05 -8.4646E-07 1.1655E-05 14 0 -8.7945E-06 -5.4352E-06 9.4961E-06 -1.3527E-06 15 0 -1.9167E-06 8.9014E-06 -3.0729E-06 -7.6435E-06 At the end of descur, fsq = 1.034187741311299E-004 ORDERING SURFACE POINTS Average elongation = 2.11049202667661 ITERATIONS RMS ERROR FORCE GRADIENT m #'s <= ON Fitting toroidal plane # 1 1 4.508E-03 4.011E-03 3.52 15 100 4.065E-04 3.063E-04 1.67 15 200 6.601E-05 1.164E-04 1.17 15 300 1.318E-05 2.240E-05 1.16 15 352 6.168E-06 9.875E-06 1.16 15 COMPUTATIONAL TIME = 8.594E-01 SECONDS ANGLE CONSTRAINTS WERE APPLIED BASED ON RM**2 + ZM**2 SPECTRUM WITH P = 4.00 AND Q = 1.00 c mb nb RmncB RmnsB ZmncB ZmnsB 0 0 1.0274E+00 0.0000E+00 -8.0091E-05 0.0000E+00 1 0 1.7868E-01 8.9199E-05 8.9199E-05 3.5698E-01 2 0 3.6034E-02 4.0806E-05 -3.5441E-05 -1.8377E-02 3 0 9.0822E-04 -6.4263E-05 7.7779E-05 -2.9605E-04 4 0 6.0848E-04 -2.7391E-05 5.8335E-06 1.7385E-03 5 0 4.1080E-04 2.4308E-05 -2.4269E-05 3.5555E-05 6 0 -8.9974E-05 3.0139E-06 3.2260E-06 -2.1615E-04 7 0 4.7820E-06 -1.3188E-05 9.9859E-06 7.5990E-05 8 0 4.4185E-05 1.7477E-06 -4.2492E-06 4.5824E-05 9 0 -1.4675E-05 6.3495E-06 -3.9067E-06 -3.2052E-05 10 0 -6.9888E-06 -1.8145E-06 3.5375E-06 -3.0077E-06 11 0 1.0180E-05 -2.7117E-06 1.3044E-06 1.3444E-05 12 0 -8.2869E-07 8.6638E-07 -1.7641E-06 -4.0095E-06 13 0 -4.6622E-06 9.1258E-07 -4.8328E-07 -3.7557E-06 14 0 6.6600E-07 -8.3740E-08 7.3147E-07 5.1341E-06 15 0 1.9039E-06 -1.2815E-07 1.1961E-07 8.3754E-07 At the end of descur, fsq = 6.168104920326876E-006 ORDERING SURFACE POINTS Average elongation = 2.21317467301387 ITERATIONS RMS ERROR FORCE GRADIENT m #'s <= ON Fitting toroidal plane # 1 1 4.678E-03 4.637E-03 2.91 15 100 4.054E-04 4.171E-04 1.47 15 200 9.123E-05 3.378E-05 1.32 15 285 3.905E-05 9.887E-06 1.31 15 COMPUTATIONAL TIME = 9.844E-01 SECONDS ANGLE CONSTRAINTS WERE APPLIED BASED ON RM**2 + ZM**2 SPECTRUM WITH P = 4.00 AND Q = 1.00 c mb nb RmncB RmnsB ZmncB ZmnsB 0 0 9.4014E-01 0.0000E+00 2.2729E-03 0.0000E+00 1 0 2.6440E-01 -3.4082E-04 -3.4082E-04 5.3039E-01 2 0 7.8742E-02 -1.2467E-03 1.9682E-03 -3.8464E-02 3 0 4.4106E-03 -8.5103E-04 2.5978E-04 -1.4078E-03 4 0 -2.1438E-06 1.4653E-05 -4.0129E-04 3.8333E-03 5 0 1.2556E-03 4.9109E-05 1.1337E-04 2.5910E-04 6 0 1.8054E-05 -8.4528E-05 1.0938E-04 -5.7876E-04 7 0 -1.0243E-04 1.0086E-06 -7.7353E-05 1.7850E-04 8 0 1.1432E-04 2.9587E-05 -3.3165E-08 1.6085E-04 9 0 2.2976E-05 -1.4720E-05 3.0617E-05 -9.4427E-05 10 0 -3.0866E-05 -1.3429E-05 -1.3220E-05 -9.4285E-06 11 0 4.1665E-06 1.1327E-05 -2.3552E-07 3.9323E-05 12 0 1.3534E-05 5.7118E-06 1.6665E-06 -1.7491E-05 13 0 -2.4836E-06 -1.0879E-05 -2.9576E-06 -5.9297E-07 14 0 -1.0061E-05 7.2060E-07 8.1189E-06 1.1310E-05 15 0 6.1003E-06 1.1983E-05 -1.2371E-06 -1.5322E-05 At the end of descur, fsq = 3.904686400075312E-005 ORDERING SURFACE POINTS Average elongation = 2.25851437972348 ITERATIONS RMS ERROR FORCE GRADIENT m #'s <= ON Fitting toroidal plane # 1 1 4.768E-03 4.962E-03 2.79 15 100 3.120E-04 3.455E-04 1.39 15 200 7.014E-05 1.587E-05 1.36 15 232 4.832E-05 9.999E-06 1.36 15 COMPUTATIONAL TIME = 1.078E+00 SECONDS ANGLE CONSTRAINTS WERE APPLIED BASED ON RM**2 + ZM**2 SPECTRUM WITH P = 4.00 AND Q = 1.00 c mb nb RmncB RmnsB ZmncB ZmnsB 0 0 9.0518E-01 0.0000E+00 2.8143E-03 0.0000E+00 1 0 2.9208E-01 -4.9059E-04 -4.9059E-04 5.8707E-01 2 0 9.5114E-02 -1.5184E-03 2.5106E-03 -4.7640E-02 3 0 6.3850E-03 -1.1356E-03 2.8757E-04 -1.6173E-03 4 0 -5.3258E-04 -6.2126E-05 -5.0114E-04 4.7885E-03 5 0 1.6314E-03 8.4150E-05 1.6612E-04 2.9975E-04 6 0 9.6590E-05 -9.2838E-05 1.2164E-04 -7.6171E-04 7 0 -1.6522E-04 -2.0593E-05 -9.2282E-05 2.3926E-04 8 0 1.5849E-04 3.5456E-05 7.6932E-06 2.2518E-04 9 0 4.2472E-05 -9.1911E-06 2.8021E-05 -1.3116E-04 10 0 -5.4859E-05 -2.0302E-05 -1.3948E-05 -1.8284E-05 11 0 8.5172E-06 1.0860E-05 4.7796E-06 5.9931E-05 12 0 2.6205E-05 9.6221E-06 -4.9753E-06 -1.9726E-05 13 0 -1.0474E-05 -1.2205E-05 -1.2384E-06 -5.6538E-06 14 0 -1.5669E-05 6.9801E-07 1.5302E-05 1.5276E-05 15 0 1.3444E-05 1.2386E-05 -8.3176E-06 -1.5026E-05 At the end of descur, fsq = 4.831631991201872E-005 OUTPUT MOMENTS surface # 1 m X-COS X-SIN Z-COS Z-SIN 0 1.100000 0.000000 0.000000 0.000000 1 0.000000 0.000000 0.000000 0.000000 2 0.000000 0.000000 0.000000 0.000000 3 0.000000 0.000000 0.000000 0.000000 4 0.000000 0.000000 0.000000 0.000000 5 0.000000 0.000000 0.000000 0.000000 6 0.000000 0.000000 0.000000 0.000000 7 0.000000 0.000000 0.000000 0.000000 8 0.000000 0.000000 0.000000 0.000000 9 0.000000 0.000000 0.000000 0.000000 10 0.000000 0.000000 0.000000 0.000000 11 0.000000 0.000000 0.000000 0.000000 12 0.000000 0.000000 0.000000 0.000000 13 0.000000 0.000000 0.000000 0.000000 14 0.000000 0.000000 0.000000 0.000000 15 0.000000 0.000000 0.000000 0.000000 surface # 5 m X-COS X-SIN Z-COS Z-SIN 0 1.067869 0.000000 -0.001890 0.000000 1 0.119494 0.000573 0.000738 0.239557 2 0.015685 0.001036 -0.001493 -0.009407 3 0.000393 -0.000225 0.000372 0.000466 4 0.000402 -0.000220 0.000226 0.000983 5 0.000081 0.000216 -0.000234 -0.000113 6 0.000047 0.000023 -0.000036 0.000059 7 0.000001 -0.000098 0.000104 0.000071 8 -0.000016 0.000038 -0.000020 -0.000009 9 0.000038 0.000034 -0.000039 0.000015 10 0.000015 -0.000037 0.000028 0.000015 11 -0.000021 -0.000003 0.000010 -0.000021 12 0.000003 0.000021 -0.000019 -0.000006 13 0.000010 -0.000008 0.000003 0.000006 14 -0.000006 -0.000008 0.000010 -0.000008 15 -0.000004 0.000006 -0.000009 -0.000007 surface # 11 m X-COS X-SIN Z-COS Z-SIN 0 0.905179 0.000000 0.002814 0.000000 1 0.292080 -0.000500 -0.000472 0.587073 2 0.095114 -0.001525 0.002508 -0.047640 3 0.006385 -0.001136 0.000287 -0.001617 4 -0.000533 -0.000062 -0.000501 0.004789 5 0.001631 0.000084 0.000166 0.000300 6 0.000097 -0.000093 0.000121 -0.000762 7 -0.000165 -0.000021 -0.000092 0.000239 8 0.000158 0.000035 0.000008 0.000225 9 0.000042 -0.000009 0.000028 -0.000131 10 -0.000055 -0.000020 -0.000014 -0.000018 11 0.000009 0.000011 0.000005 0.000060 12 0.000026 0.000010 -0.000005 -0.000020 13 -0.000010 -0.000012 -0.000001 -0.000006 14 -0.000016 0.000001 0.000015 0.000015 15 0.000013 0.000012 -0.000008 -0.000015 SUCCESSFUL END OF TEST DRIVE