Advertisement
pVinc

kowalczyk_szymański

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