Subversion Repositories Nec2c

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. /*** Translated to the C language by N. Kyriazis  20 Aug 2003 ***
  2.  
  3.  Program NEC(input,tape5=input,output,tape11,tape12,tape13,tape14,
  4.  tape15,tape16,tape20,tape21)
  5.  
  6.  Numerical Electromagnetics Code (NEC2)  developed at Lawrence
  7.  Livermore lab., Livermore, CA.  (contact G. Burke at 415-422-8414
  8.  for problems with the NEC code. For problems with the vax implem-
  9.  entation, contact J. Breakall at 415-422-8196 or E. Domning at 415
  10.  422-5936)
  11.  file created 4/11/80.
  12.  
  13.                 ***********Notice**********
  14.  This computer code material was prepared as an account of work
  15.  sponsored by the United States government.  Neither the United
  16.  States nor the United States Department Of Energy, nor any of
  17.  their employees, nor any of their contractors, subcontractors,
  18.  or their employees, makes any warranty, express or implied, or
  19.  assumes any legal liability or responsibility for the accuracy,
  20.  completeness or usefulness of any information, apparatus, product
  21.  or process disclosed, or represents that its use would not infringe
  22.  privately-owned rights.
  23.  
  24. *******************************************************************/
  25.  
  26. #include "nec2c.h"
  27.  
  28. /* common  /netcx/ */
  29. extern netcx_t netcx;
  30.  
  31. /* common  /vsorc/ */
  32. extern vsorc_t vsorc;
  33.  
  34. /* common  /data/ */
  35. extern data_t data;
  36.  
  37. /* common  /crnt/ */
  38. extern crnt_t crnt;
  39.  
  40. /* pointers to input/output files */
  41. extern FILE *input_fp, *output_fp, *plot_fp;
  42.  
  43. /*-------------------------------------------------------------------*/
  44.  
  45. /* subroutine netwk solves for structure currents for a given */
  46. /* excitation including the effect of non-radiating networks if */
  47. /* present. */
  48. void netwk (complex double *cm, int *ip, complex double *einc)
  49. {
  50.         int *ipnt = NULL, *nteqa = NULL, *ntsca = NULL;
  51.         int jump1, jump2, nteq = 0, ntsc = 0, nseg2, irow2 = 0, j, ndimn;
  52.         int neqz2, neqt, irow1 = 0, i, nseg1, isc1 = 0, isc2 = 0;
  53.         double asmx, asa, pwr, y11r, y11i, y12r, y12i, y22r, y22i;
  54.         complex double *vsrc = NULL, *rhs = NULL, *cmn = NULL;
  55.         complex double *rhnt = NULL, *rhnx = NULL, ymit, vlt, cux;
  56.  
  57.         neqz2 = netcx.neq2;
  58.         if (neqz2 == 0)
  59.                 neqz2 = 1;
  60.  
  61.         netcx.pin = 0.;
  62.         netcx.pnls = 0.;
  63.         neqt = netcx.neq + netcx.neq2;
  64.         ndimn = j = (2 * netcx.nonet + vsorc.nsant);
  65.  
  66.         /* Allocate network buffers */
  67.         if (netcx.nonet != 0)
  68.         {
  69.                 mem_alloc ((void *) &rhs, data.np3m * sizeof (complex double));
  70.  
  71.                 i = j * sizeof (complex double);
  72.                 mem_alloc ((void *) &rhnt, i);
  73.                 mem_alloc ((void *) &rhnx, i);
  74.                 mem_alloc ((void *) &cmn, i * j);
  75.  
  76.                 i = j * sizeof (int);
  77.                 mem_alloc ((void *) &ntsca, i);
  78.                 mem_alloc ((void *) &nteqa, i);
  79.                 mem_alloc ((void *) &ipnt, i);
  80.  
  81.                 mem_alloc ((void *) &vsrc, vsorc.nsant * sizeof (complex double));
  82.         }
  83.         else if (netcx.masym != 0)
  84.         {
  85.                 i = j * sizeof (int);
  86.                 mem_alloc ((void *) &ipnt, i);
  87.         }
  88.  
  89.         if (netcx.ntsol == 0)
  90.         {
  91.                 /* compute relative matrix asymmetry */
  92.                 if (netcx.masym != 0)
  93.                 {
  94.                         irow1 = 0;
  95.                         if (netcx.nonet != 0)
  96.                         {
  97.                                 for (i = 0; i < netcx.nonet; i++)
  98.                                 {
  99.                                         nseg1 = netcx.iseg1[i];
  100.                                         for (isc1 = 0; isc1 < 2; isc1++)
  101.                                         {
  102.                                                 if (irow1 == 0)
  103.                                                 {
  104.                                                         ipnt[irow1] = nseg1;
  105.                                                         nseg1 = netcx.iseg2[i];
  106.                                                         irow1++;
  107.                                                         continue;
  108.                                                 }
  109.  
  110.                                                 for (j = 0; j < irow1; j++)
  111.                                                         if (nseg1 == ipnt[j])
  112.                                                                 break;
  113.  
  114.                                                 if (j == irow1)
  115.                                                 {
  116.                                                         ipnt[irow1] = nseg1;
  117.                                                         irow1++;
  118.                                                 }
  119.  
  120.                                                 nseg1 = netcx.iseg2[i];
  121.  
  122.                                         } /* for( isc1 = 0; isc1 < 2; isc1++ ) */
  123.  
  124.                                 } /* for( i = 0; i < netcx.nonet; i++ ) */
  125.  
  126.                         } /* if( netcx.nonet != 0) */
  127.  
  128.                         if (vsorc.nsant != 0)
  129.                         {
  130.                                 for (i = 0; i < vsorc.nsant; i++)
  131.                                 {
  132.                                         nseg1 = vsorc.isant[i];
  133.                                         if (irow1 == 0)
  134.                                         {
  135.                                                 ipnt[irow1] = nseg1;
  136.                                                 irow1++;
  137.                                                 continue;
  138.                                         }
  139.  
  140.                                         for (j = 0; j < irow1; j++)
  141.                                                 if (nseg1 == ipnt[j])
  142.                                                         break;
  143.  
  144.                                         if (j == irow1)
  145.                                         {
  146.                                                 ipnt[irow1] = nseg1;
  147.                                                 irow1++;
  148.                                         }
  149.  
  150.                                 } /* for( i = 0; i < vsorc.nsant; i++ ) */
  151.  
  152.                         } /* if( vsorc.nsant != 0) */
  153.  
  154.                         if (irow1 >= 2)
  155.                         {
  156.                                 for (i = 0; i < irow1; i++)
  157.                                 {
  158.                                         isc1 = ipnt[i] - 1;
  159.                                         asmx = data.si[isc1];
  160.  
  161.                                         for (j = 0; j < neqt; j++)
  162.                                                 rhs[j] = CPLX_00;
  163.  
  164.                                         rhs[isc1] = CPLX_10;
  165.                                         solves (
  166.                                             cm,
  167.                                             ip,
  168.                                             rhs,
  169.                                             netcx.neq,
  170.                                             1,
  171.                                             data.np,
  172.                                             data.n,
  173.                                             data.mp,
  174.                                             data.m);
  175.                                         cabc (rhs);
  176.  
  177.                                         for (j = 0; j < irow1; j++)
  178.                                         {
  179.                                                 isc1 = ipnt[j] - 1;
  180.                                                 cmn[j + i * ndimn] = rhs[isc1] / asmx;
  181.                                         }
  182.  
  183.                                 } /* for( i = 0; i < irow1; i++ ) */
  184.  
  185.                                 asmx = 0.;
  186.                                 asa = 0.;
  187.  
  188.                                 for (i = 1; i < irow1; i++)
  189.                                 {
  190.                                         isc1 = i;
  191.                                         for (j = 0; j < isc1; j++)
  192.                                         {
  193.                                                 cux = cmn[i + j * ndimn];
  194.                                                 pwr = cabsl ((cux - cmn[j + i * ndimn]) / cux);
  195.                                                 asa += pwr * pwr;
  196.  
  197.                                                 if (pwr < asmx)
  198.                                                         continue;
  199.  
  200.                                                 asmx = pwr;
  201.                                                 nteq = ipnt[i];
  202.                                                 ntsc = ipnt[j];
  203.  
  204.                                         } /* for( j = 0; j < isc1; j++ ) */
  205.  
  206.                                 } /* for( i = 1; i < irow1; i++ ) */
  207.  
  208.                                 asa = sqrtl (asa * 2. / (double) (irow1 * (irow1 - 1)));
  209.                                 fprintf (
  210.                                     output_fp,
  211.                                     "\n\n"
  212.                                     "   MAXIMUM RELATIVE ASYMMETRY OF THE DRIVING POINT "
  213.                                     "ADMITTANCE\n"
  214.                                     "   MATRIX IS %10.3E FOR SEGMENTS %d AND %d\n"
  215.                                     "   RMS RELATIVE ASYMMETRY IS %10.3E",
  216.                                     asmx,
  217.                                     nteq,
  218.                                     ntsc,
  219.                                     asa);
  220.  
  221.                         } /* if( irow1 >= 2) */
  222.  
  223.                 } /* if( netcx.masym != 0) */
  224.  
  225.                 /* solution of network equations */
  226.                 if (netcx.nonet != 0)
  227.                 {
  228.                         for (i = 0; i < ndimn; i++)
  229.                         {
  230.                                 rhnx[i] = CPLX_00;
  231.                                 for (j = 0; j < ndimn; j++)
  232.                                         cmn[j + i * ndimn] = CPLX_00;
  233.                         }
  234.  
  235.                         /* sort network and source data and */
  236.                         /* assign equation numbers to segments */
  237.                         nteq = 0;
  238.                         ntsc = 0;
  239.  
  240.                         for (j = 0; j < netcx.nonet; j++)
  241.                         {
  242.                                 nseg1 = netcx.iseg1[j];
  243.                                 nseg2 = netcx.iseg2[j];
  244.  
  245.                                 if (netcx.ntyp[j] <= 1)
  246.                                 {
  247.                                         y11r = netcx.x11r[j];
  248.                                         y11i = netcx.x11i[j];
  249.                                         y12r = netcx.x12r[j];
  250.                                         y12i = netcx.x12i[j];
  251.                                         y22r = netcx.x22r[j];
  252.                                         y22i = netcx.x22i[j];
  253.                                 }
  254.                                 else
  255.                                 {
  256.                                         y22r = TP * netcx.x11i[j] / data.wlam;
  257.                                         y12r = 0.;
  258.                                         y12i = 1. / (netcx.x11r[j] * sinl (y22r));
  259.                                         y11r = netcx.x12r[j];
  260.                                         y11i = -y12i * cosl (y22r);
  261.                                         y22r = netcx.x22r[j];
  262.                                         y22i = y11i + netcx.x22i[j];
  263.                                         y11i = y11i + netcx.x12i[j];
  264.  
  265.                                         if (netcx.ntyp[j] != 2)
  266.                                         {
  267.                                                 y12r = -y12r;
  268.                                                 y12i = -y12i;
  269.                                         }
  270.  
  271.                                 } /* if( netcx.ntyp[j] <= 1) */
  272.  
  273.                                 jump1 = FALSE;
  274.                                 if (vsorc.nsant != 0)
  275.                                 {
  276.                                         for (i = 0; i < vsorc.nsant; i++)
  277.                                                 if (nseg1 == vsorc.isant[i])
  278.                                                 {
  279.                                                         isc1 = i;
  280.                                                         jump1 = TRUE;
  281.                                                         break;
  282.                                                 }
  283.                                 } /* if( vsorc.nsant != 0) */
  284.  
  285.                                 jump2 = FALSE;
  286.                                 if (!jump1)
  287.                                 {
  288.                                         isc1 = -1;
  289.  
  290.                                         if (nteq != 0)
  291.                                         {
  292.                                                 for (i = 0; i < nteq; i++)
  293.                                                         if (nseg1 == nteqa[i])
  294.                                                         {
  295.                                                                 irow1 = i;
  296.                                                                 jump2 = TRUE;
  297.                                                                 break;
  298.                                                         }
  299.  
  300.                                         } /* if( nteq != 0) */
  301.  
  302.                                         if (!jump2)
  303.                                         {
  304.                                                 irow1 = nteq;
  305.                                                 nteqa[nteq] = nseg1;
  306.                                                 nteq++;
  307.                                         }
  308.  
  309.                                 } /* if( ! jump1 ) */
  310.                                 else
  311.                                 {
  312.                                         if (ntsc != 0)
  313.                                         {
  314.                                                 for (i = 0; i < ntsc; i++)
  315.                                                 {
  316.                                                         if (nseg1 == ntsca[i])
  317.                                                         {
  318.                                                                 irow1 = ndimn - (i + 1);
  319.                                                                 jump2 = TRUE;
  320.                                                                 break;
  321.                                                         }
  322.                                                 }
  323.  
  324.                                         } /* if( ntsc != 0) */
  325.  
  326.                                         if (!jump2)
  327.                                         {
  328.                                                 irow1 = ndimn - (ntsc + 1);
  329.                                                 ntsca[ntsc] = nseg1;
  330.                                                 vsrc[ntsc] = vsorc.vsant[isc1];
  331.                                                 ntsc++;
  332.                                         }
  333.  
  334.                                 } /* if( ! jump1 ) */
  335.  
  336.                                 jump1 = FALSE;
  337.                                 if (vsorc.nsant != 0)
  338.                                 {
  339.                                         for (i = 0; i < vsorc.nsant; i++)
  340.                                         {
  341.                                                 if (nseg2 == vsorc.isant[i])
  342.                                                 {
  343.                                                         isc2 = i;
  344.                                                         jump1 = TRUE;
  345.                                                         break;
  346.                                                 }
  347.                                         }
  348.  
  349.                                 } /* if( vsorc.nsant != 0) */
  350.  
  351.                                 jump2 = FALSE;
  352.                                 if (!jump1)
  353.                                 {
  354.                                         isc2 = -1;
  355.  
  356.                                         if (nteq != 0)
  357.                                         {
  358.                                                 for (i = 0; i < nteq; i++)
  359.                                                         if (nseg2 == nteqa[i])
  360.                                                         {
  361.                                                                 irow2 = i;
  362.                                                                 jump2 = TRUE;
  363.                                                                 break;
  364.                                                         }
  365.  
  366.                                         } /* if( nteq != 0) */
  367.  
  368.                                         if (!jump2)
  369.                                         {
  370.                                                 irow2 = nteq;
  371.                                                 nteqa[nteq] = nseg2;
  372.                                                 nteq++;
  373.                                         }
  374.  
  375.                                 } /* if( ! jump1 ) */
  376.                                 else
  377.                                 {
  378.                                         if (ntsc != 0)
  379.                                         {
  380.                                                 for (i = 0; i < ntsc; i++)
  381.                                                         if (nseg2 == ntsca[i])
  382.                                                         {
  383.                                                                 irow2 = ndimn - (i + 1);
  384.                                                                 jump2 = TRUE;
  385.                                                                 break;
  386.                                                         }
  387.  
  388.                                         } /* if( ntsc != 0) */
  389.  
  390.                                         if (!jump2)
  391.                                         {
  392.                                                 irow2 = ndimn - (ntsc + 1);
  393.                                                 ntsca[ntsc] = nseg2;
  394.                                                 vsrc[ntsc] = vsorc.vsant[isc2];
  395.                                                 ntsc++;
  396.                                         }
  397.  
  398.                                 } /* if( ! jump1 ) */
  399.  
  400.                                 /* fill network equation matrix and right hand side vector with
  401.                                  */
  402.                                 /* network short-circuit admittance matrix coefficients. */
  403.                                 if (isc1 == -1)
  404.                                 {
  405.                                         cmn[irow1 + irow1 * ndimn] -=
  406.                                             cmplx (y11r, y11i) * data.si[nseg1 - 1];
  407.                                         cmn[irow1 + irow2 * ndimn] -=
  408.                                             cmplx (y12r, y12i) * data.si[nseg1 - 1];
  409.                                 }
  410.                                 else
  411.                                 {
  412.                                         rhnx[irow1] +=
  413.                                             cmplx (y11r, y11i) * vsorc.vsant[isc1] / data.wlam;
  414.                                         rhnx[irow2] +=
  415.                                             cmplx (y12r, y12i) * vsorc.vsant[isc1] / data.wlam;
  416.                                 }
  417.  
  418.                                 if (isc2 == -1)
  419.                                 {
  420.                                         cmn[irow2 + irow2 * ndimn] -=
  421.                                             cmplx (y22r, y22i) * data.si[nseg2 - 1];
  422.                                         cmn[irow2 + irow1 * ndimn] -=
  423.                                             cmplx (y12r, y12i) * data.si[nseg2 - 1];
  424.                                 }
  425.                                 else
  426.                                 {
  427.                                         rhnx[irow1] +=
  428.                                             cmplx (y12r, y12i) * vsorc.vsant[isc2] / data.wlam;
  429.                                         rhnx[irow2] +=
  430.                                             cmplx (y22r, y22i) * vsorc.vsant[isc2] / data.wlam;
  431.                                 }
  432.  
  433.                         } /* for( j = 0; j < netcx.nonet; j++ ) */
  434.  
  435.                         /* add interaction matrix admittance */
  436.                         /* elements to network equation matrix */
  437.                         for (i = 0; i < nteq; i++)
  438.                         {
  439.                                 for (j = 0; j < neqt; j++)
  440.                                         rhs[j] = CPLX_00;
  441.  
  442.                                 irow1 = nteqa[i] - 1;
  443.                                 rhs[irow1] = CPLX_10;
  444.                                 solves (
  445.                                     cm,
  446.                                     ip,
  447.                                     rhs,
  448.                                     netcx.neq,
  449.                                     1,
  450.                                     data.np,
  451.                                     data.n,
  452.                                     data.mp,
  453.                                     data.m);
  454.                                 cabc (rhs);
  455.  
  456.                                 for (j = 0; j < nteq; j++)
  457.                                 {
  458.                                         irow1 = nteqa[j] - 1;
  459.                                         cmn[i + j * ndimn] += rhs[irow1];
  460.                                 }
  461.  
  462.                         } /* for( i = 0; i < nteq; i++ ) */
  463.  
  464.                         /* factor network equation matrix */
  465.                         factr (nteq, cmn, ipnt, ndimn);
  466.  
  467.                 } /* if( netcx.nonet != 0) */
  468.  
  469.         } /* if( netcx.ntsol != 0) */
  470.  
  471.         if (netcx.nonet != 0)
  472.         {
  473.                 /* add to network equation right hand side */
  474.                 /* the terms due to element interactions */
  475.                 for (i = 0; i < neqt; i++)
  476.                         rhs[i] = einc[i];
  477.  
  478.                 solves (cm, ip, rhs, netcx.neq, 1, data.np, data.n, data.mp, data.m);
  479.                 cabc (rhs);
  480.  
  481.                 for (i = 0; i < nteq; i++)
  482.                 {
  483.                         irow1 = nteqa[i] - 1;
  484.                         rhnt[i] = rhnx[i] + rhs[irow1];
  485.                 }
  486.  
  487.                 /* solve network equations */
  488.                 solve (nteq, cmn, ipnt, rhnt, ndimn);
  489.  
  490.                 /* add fields due to network voltages to electric fields */
  491.                 /* applied to structure and solve for induced current */
  492.                 for (i = 0; i < nteq; i++)
  493.                 {
  494.                         irow1 = nteqa[i] - 1;
  495.                         einc[irow1] -= rhnt[i];
  496.                 }
  497.  
  498.                 solves (cm, ip, einc, netcx.neq, 1, data.np, data.n, data.mp, data.m);
  499.                 cabc (einc);
  500.  
  501.                 if (netcx.nprint == 0)
  502.                 {
  503.                         fprintf (
  504.                             output_fp,
  505.                             "\n\n\n"
  506.                             "                          "
  507.                             "--------- STRUCTURE EXCITATION DATA AT NETWORK CONNECTION POINTS "
  508.                             "--------");
  509.  
  510.                         fprintf (
  511.                             output_fp,
  512.                             "\n"
  513.                             "  TAG   SEG.      VOLTAGE (VOLTS)          CURRENT (AMPS)        "
  514.                             " IMPEDANCE (OHMS)       ADMITTANCE (MHOS)     POWER\n"
  515.                             "  NO.   NO.     REAL      IMAGINARY     REAL      IMAGINARY    "
  516.                             " REAL      IMAGINARY     REAL      IMAGINARY   (WATTS)");
  517.                 }
  518.  
  519.                 for (i = 0; i < nteq; i++)
  520.                 {
  521.                         irow1 = nteqa[i] - 1;
  522.                         vlt = rhnt[i] * data.si[irow1] * data.wlam;
  523.                         cux = einc[irow1] * data.wlam;
  524.                         ymit = cux / vlt;
  525.                         netcx.zped = vlt / cux;
  526.                         irow2 = data.itag[irow1];
  527.                         pwr = .5 * creall (vlt * conjl (cux));
  528.                         netcx.pnls = netcx.pnls - pwr;
  529.  
  530.                         if (netcx.nprint == 0)
  531.                                 fprintf (
  532.                                     output_fp,
  533.                                     "\n"
  534.                                     " %4d %5d %11.4E %11.4E %11.4E %11.4E"
  535.                                     " %11.4E %11.4E %11.4E %11.4E %11.4E",
  536.                                     irow2,
  537.                                     irow1 + 1,
  538.                                     print_creall (vlt),
  539.                                     print_cimagl (vlt),
  540.                                     print_creall (cux),
  541.                                     print_cimagl (cux),
  542.                                     print_creall (netcx.zped),
  543.                                     print_cimagl (netcx.zped),
  544.                                     print_creall (ymit),
  545.                                     print_cimagl (ymit),
  546.                                     pwr);
  547.                 }
  548.  
  549.                 if (ntsc != 0)
  550.                 {
  551.                         for (i = 0; i < ntsc; i++)
  552.                         {
  553.                                 irow1 = ntsca[i] - 1;
  554.                                 vlt = vsrc[i];
  555.                                 cux = einc[irow1] * data.wlam;
  556.                                 ymit = cux / vlt;
  557.                                 netcx.zped = vlt / cux;
  558.                                 irow2 = data.itag[irow1];
  559.                                 pwr = .5 * creall (vlt * conjl (cux));
  560.                                 netcx.pnls = netcx.pnls - pwr;
  561.  
  562.                                 if (netcx.nprint == 0)
  563.                                         fprintf (
  564.                                             output_fp,
  565.                                             "\n"
  566.                                             " %4d %5d %11.4E %11.4E %11.4E %11.4E"
  567.                                             " %11.4E %11.4E %11.4E %11.4E %11.4E",
  568.                                             irow2,
  569.                                             irow1 + 1,
  570.                                             print_creall (vlt),
  571.                                             print_cimagl (vlt),
  572.                                             print_creall (cux),
  573.                                             print_cimagl (cux),
  574.                                             print_creall (netcx.zped),
  575.                                             print_cimagl (netcx.zped),
  576.                                             print_creall (ymit),
  577.                                             print_cimagl (ymit),
  578.                                             pwr);
  579.  
  580.                         } /* for( i = 0; i < ntsc; i++ ) */
  581.  
  582.                 } /* if( ntsc != 0) */
  583.  
  584.         } /* if( netcx.nonet != 0) */
  585.         else
  586.         {
  587.                 /* solve for currents when no networks are present */
  588.                 solves (cm, ip, einc, netcx.neq, 1, data.np, data.n, data.mp, data.m);
  589.                 cabc (einc);
  590.                 ntsc = 0;
  591.         }
  592.  
  593.         if ((vsorc.nsant + vsorc.nvqd) == 0)
  594.                 return;
  595.  
  596.         fprintf (
  597.             output_fp,
  598.             "\n\n\n"
  599.             "                                          "
  600.             "- - - ANTENNA INPUT PARAMETERS - - -\n");
  601.  
  602.         fprintf (
  603.             output_fp,
  604.             "\n"
  605.             "   TAG   SEG.    VOLTAGE (VOLTS)         CURRENT (AMPS)     "
  606.             "    IMPEDANCE (OHMS)        ADMITTANCE (MHOS)      POWER\n"
  607.             "   NO.   NO.    REAL        IMAG.       REAL        IMAG.   "
  608.             "    REAL        IMAG.       REAL        IMAG.     (WATTS)");
  609.  
  610.         if (vsorc.nsant != 0)
  611.         {
  612.                 for (i = 0; i < vsorc.nsant; i++)
  613.                 {
  614.                         isc1 = vsorc.isant[i] - 1;
  615.                         vlt = vsorc.vsant[i];
  616.  
  617.                         if (ntsc == 0)
  618.                         {
  619.                                 cux = einc[isc1] * data.wlam;
  620.                                 irow1 = 0;
  621.                         }
  622.                         else
  623.                         {
  624.                                 for (j = 0; j < ntsc; j++)
  625.                                         if (ntsca[j] == isc1 + 1)
  626.                                                 break;
  627.  
  628.                                 irow1 = ndimn - (j + 1);
  629.                                 cux = rhnx[irow1];
  630.                                 for (j = 0; j < nteq; j++)
  631.                                         cux -= cmn[j + irow1 * ndimn] * rhnt[j];
  632.                                 cux = (einc[isc1] + cux) * data.wlam;
  633.                                 irow1++;
  634.  
  635.                         } /* if( ntsc == 0) */
  636.  
  637.                         ymit = cux / vlt;
  638.                         netcx.zped = vlt / cux;
  639.                         pwr = .5 * creall (vlt * conjl (cux));
  640.                         netcx.pin = netcx.pin + pwr;
  641.  
  642.                         if (irow1 != 0)
  643.                                 netcx.pnls = netcx.pnls + pwr;
  644.  
  645.                         irow2 = data.itag[isc1];
  646.                         fprintf (
  647.                             output_fp,
  648.                             "\n"
  649.                             "%6d%6d%12.5E%12.5E%12.5E%12.5E"
  650.                             "%12.5E%12.5E%12.5E%12.5E%12.5E",
  651.                             irow2,
  652.                             isc1 + 1,
  653.                             print_creall (vlt),
  654.                             print_cimagl (vlt),
  655.                             print_creall (cux),
  656.                             print_cimagl (cux),
  657.                             print_creall (netcx.zped),
  658.                             print_cimagl (netcx.zped),
  659.                             print_creall (ymit),
  660.                             print_cimagl (ymit),
  661.                             pwr);
  662.  
  663.                 } /* for( i = 0; i < vsorc.nsant; i++ ) */
  664.  
  665.         } /* if( vsorc.nsant != 0) */
  666.  
  667.         if (vsorc.nvqd == 0)
  668.                 return;
  669.  
  670.         for (i = 0; i < vsorc.nvqd; i++)
  671.         {
  672.                 isc1 = vsorc.ivqd[i] - 1;
  673.                 vlt = vsorc.vqd[i];
  674.                 cux = cmplx (crnt.air[isc1], crnt.aii[isc1]);
  675.                 ymit = cmplx (crnt.bir[isc1], crnt.bii[isc1]);
  676.                 netcx.zped = cmplx (crnt.cir[isc1], crnt.cii[isc1]);
  677.                 pwr = data.si[isc1] * TP * .5;
  678.                 cux = (cux - ymit * sinl (pwr) + netcx.zped * cosl (pwr)) * data.wlam;
  679.                 ymit = cux / vlt;
  680.                 netcx.zped = vlt / cux;
  681.                 pwr = .5 * creall (vlt * conjl (cux));
  682.                 netcx.pin = netcx.pin + pwr;
  683.                 irow2 = data.itag[isc1];
  684.  
  685.                 fprintf (
  686.                     output_fp,
  687.                     "\n"
  688.                     "%6d%6d%12.5E%12.5E%12.5E%12.5E"
  689.                     "%12.5E%12.5E%12.5E%12.5E%12.5E",
  690.                     irow2,
  691.                     isc1 + 1,
  692.                     print_creall (vlt),
  693.                     print_cimagl (vlt),
  694.                     print_creall (cux),
  695.                     print_cimagl (cux),
  696.                     print_creall (netcx.zped),
  697.                     print_cimagl (netcx.zped),
  698.                     print_creall (ymit),
  699.                     print_cimagl (ymit),
  700.                     pwr);
  701.  
  702.         } /* for( i = 0; i < vsorc.nvqd; i++ ) */
  703.  
  704.         /* Free network buffers */
  705.         free_ptr ((void *) &ipnt);
  706.         free_ptr ((void *) &nteqa);
  707.         free_ptr ((void *) &ntsca);
  708.         free_ptr ((void *) &vsrc);
  709.         free_ptr ((void *) &rhs);
  710.         free_ptr ((void *) &cmn);
  711.         free_ptr ((void *) &rhnt);
  712.         free_ptr ((void *) &rhnx);
  713.  
  714.         return;
  715. }
  716.  
  717. /*-----------------------------------------------------------------------*/
  718.