Advertisement
pVinc

volkmer

Oct 27th, 2021
1,179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.52 KB | None | 0 0
  1.             N = 4;
  2.             numericUpDown1.Value = N;
  3.             UstawTablice();
  4.             int blad;
  5.             AZ = new Complex[N + 1, N + 1];
  6.             BZ = new Complex[N + 1];
  7.             XZ = new Complex[N + 1];
  8.  
  9.             double R1 = 10, R2 = R1, XL = R1, XC = R1;
  10.             Complex E1 = 200, E2 = 100;
  11.  
  12.             AZ[1, 1] = 1; AZ[1, 2] = -1; AZ[1, 3] = -1; AZ[1, 4] = -1;
  13.             AZ[2, 1] = R1; AZ[2, 2] = new Complex(0, XL); AZ[2, 3] = 0; AZ[2, 4] = 0;
  14.             AZ[3, 1] = 0; AZ[3, 2] = new Complex(0, -XL); AZ[3, 3] = new Complex(0, -XC); AZ[3, 4] = 0;
  15.             AZ[4, 1] = 0; AZ[4, 2] = 0; AZ[4, 3] = new Complex(0, XC); AZ[4, 4] = R2;
  16.  
  17.             BZ[1] = Complex.Zero;
  18.             BZ[2] = E1;
  19.             BZ[3] = -E2;
  20.             BZ[4] = E2;
  21.  
  22.             for (int i = 1; i <= N; i++)
  23.             {
  24.                 for (int j = 1; j <= N; j++)
  25.                 {
  26.                     MacierzA.Rows[i - 1].Cells[j - 1].Value = AZ[i, j].ToString();
  27.                 }
  28.                 WektorB.Rows[i - 1].Cells[0].Value = BZ[i].ToString();
  29.             }
  30.             if (radioButton1.Checked)
  31.             {
  32.                 blad = MetodaGaussa.RozRowMacGaussa(AZ, BZ, XZ, 1e-30);
  33.             }
  34.             else
  35.             {
  36.                 blad = MetodaRozkladuLU.RozRowMacCroutDoolitta(AZ, BZ, XZ, 1e-30);
  37.             }
  38.             if (blad == 0)
  39.                 for (int i = 1; i <= N; i++)
  40.                     WektorX[0, i - 1].Value = XZ[i].ToString("0.000000");
  41.  
  42.  
  43.             textBox1.Text = "IpK bilans: " + (XZ[1] - XZ[2] - XZ[3] - XZ[4]).ToString();
  44.             textBox2.Text = "IIpK bilans: " + (E1 - XZ[1]*R1 - XZ[2]*(Complex.j*XL)).ToString();
  45.  
  46.             double Pz = (E1 * XZ[1].Conjugate - E2 * XZ[3].Conjugate).Re;
  47.  
  48.             textBox3.Text = "  Pz = " + Pz.ToString();
  49.  
  50.             double Podb = (XZ[1] * XZ[1].Conjugate * R1).Re + (XZ[2] * XZ[2].Conjugate * (Complex.j * XL)).Re + (XZ[3] * XZ[3].Conjugate * (-Complex.j * XC)).Re + (XZ[4] * XZ[4].Conjugate * R2).Re;
  51.            
  52.             textBox4.Text = "Podb = " + Podb.ToString();
  53.  
  54.             Complex Sz = new Complex(0, 0);
  55.            
  56.             Sz = E1 * XZ[1].Conjugate - E2 * XZ[3].Conjugate;
  57.  
  58.             textBox5.Text = "  Sz= " + Sz.ToString();
  59.  
  60.             Complex Sodb = new Complex(0, 0);
  61.  
  62.             Sodb = (XZ[1] * XZ[1].Conjugate * R1) + (XZ[2]*XZ[2].Conjugate*(Complex.j*XL)) + (XZ[3]*XZ[3].Conjugate*(-Complex.j*XC))+(XZ[4]*XZ[4].Conjugate*R2);
  63.  
  64.             textBox6.Text = "Sodb = " + Sodb.ToString();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement