System. Collections. Generic


Download 17.71 Kb.
Sana07.09.2020
Hajmi17.71 Kb.
#128719
Bog'liq
using System


using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using System.Windows.Forms;

using System.Windows.Forms.DataVisualization.Charting;

namespace chiziqsiz_tenglama

{

public partial class Form1 : Form

{

public Form1()

{

InitializeComponent();

}

double u0x(double x, double sigma)

{



double a = Convert.ToDouble(textBox1.Text);

double gamma = Convert.ToDouble(textBox3.Text);

double betta = Convert.ToDouble(textBox4.Text);

double bett =(betta-1)/(betta-sigma-1);

int T1 = 10;

double c = 1;

double func = Math.Pow(T1,1.0/(1-betta))*Math.Pow(c - sigma*(betta-sigma-1) / (4*a) * x * x*gamma*Math.Pow(T1,bett), 1.0 / sigma);

return func;

}

double u1(double t)

{

double a = Convert.ToDouble(textBox1.Text);

double sigma = Convert.ToDouble(textBox2.Text);

double gamma = Convert.ToDouble(textBox3.Text);

double betta = Convert.ToDouble(textBox4.Text);

int T1 = 10;

double c = 1;

double func =Math.Pow(T1+gamma*(betta-1)*t,1.0/(1-betta))*Math.Pow(c, 1.0 / sigma);

return func;
}
double u2(double t)

{

double a = Convert.ToDouble(textBox1.Text);

double sigma = Convert.ToDouble(textBox2.Text);

double gamma = Convert.ToDouble(textBox3.Text);

double betta = Convert.ToDouble(textBox4.Text);

double bett = (betta - 1) / (betta - sigma - 1);

int T1 = 10;

double c = 1;

double func = Math.Pow(T1 + gamma * (betta - 1) * t, 1.0 / (1 - betta)) * Math.Pow(c - sigma * (betta - sigma - 1) / (4 * a) * gamma * Math.Pow(T1, bett), 1.0 / sigma);

return func;
}
double max(double[,] u, double[,] u3, int n, int j)

{

double maxu = Math.Abs(u[0, j] - u3[0, j]);


for (int i = 0; i < n; i++)

{

if (Math.Abs(u[i, j] - u3[i, j]) > maxu)

maxu = Math.Abs(u[i, j] - u3[i, j]);

}

return maxu;

}
private void button1_Click(object sender, EventArgs e)

{

double sigma, T;

sigma = Convert.ToDouble(textBox2.Text);

if (sigma > 0)

{
T = Convert.ToDouble(textBox5.Text);

int n = 50, m = 40;

double tau, h, eps = 0.001;

h = 1.0 / n;

tau = T / m;

double[] x = new double[n + 1];

double[] t = new double[m + 1];

double[,] u = new double[n + 1, m + 1];

double[,] u3 = new double[n + 1, m + 1];

double[] A = new double[n];

double[] B = new double[n];

double[] C = new double[n];

double[] F = new double[n];

double[] alfa = new double[n];

double[] betta = new double[n];

int s;

double gamma = Convert.ToDouble(textBox3.Text);

for (int i = 0; i < n + 1; i++)

x[i] = i * h;

for (int j = 0; j < m + 1; j++)

t[j] = j * tau;

for (int i = 0; i < n + 1; i++)

u[i, 0] = u0x(x[i], sigma);

for (int j = 0; j < m + 1; j++)

{

u[0, j] = u1(t[j]);

u[n - 1, j] = u2(t[j]);

}

for (int j = 1; j < m + 1; j++)

{
s = 0;
int i = 1;

{

alfa[i] = 0;

betta[i] = u[0, j];

}

for (i = 2; i < n; i++)

{

A[i] = tau / (h * h) * (Math.Pow(u[i, j - 1], sigma) + Math.Pow(u[i - 1, j - 1], sigma)) / 2;

B[i] = tau / (h * h) * (Math.Pow(u[i + 1, j - 1], sigma) + Math.Pow(u[i, j - 1], sigma)) / 2;

F[i] = u[i, j - 1];

C[i] =

alfa[i] = B[i] / (C[i] - A[i] * alfa[i - 1]);

betta[i] = (A[i] * betta[i - 1] + F[i]) / (C[i] - A[i] * alfa[i - 1]);
}
for (i = n - 1; i > 0; i--)

{

u[i, j] = alfa[i] * u[i + 1, j] + betta[i];

}

do

{

s++;

for (i = 0; i < n + 1; i++)

{

u3[i, j] = u[i, j];
}

i = 1;

{

alfa[i] = 0;

betta[i] = u[0, j];

}

for (i = 2; i < n; i++)

{

A[i] = tau / (h * h) * (Math.Pow(u[i, j - 1], sigma) + Math.Pow(u[i - 1, j - 1], sigma)) / 2;

B[i] = tau / (h * h) * (Math.Pow(u[i + 1, j - 1], sigma) + Math.Pow(u[i, j - 1], sigma)) / 2;

F[i] = u[i, j - 1];

C[i] =

alfa[i] = B[i] / (C[i] - A[i] * alfa[i - 1]);

betta[i] = (A[i] * betta[i - 1] + F[i]) / (C[i] - A[i] * alfa[i - 1]);
}
for (i = n - 1; i > 0; i--)

{

u[i, j] = alfa[i] * u[i + 1, j] + betta[i];

}


} while (max(u, u3, n, j) >= eps);
}

//for (int i = 0; i < n + 1; i++)

// for (int j = 0; j < m + 1; j++)

// u[i, j] = Math.Pow(2 * (sigma + 1) * (sigma + 2) * Math.Pow((8 + t[j]), 2 / (sigma + 1)) / sigma, 1 / 2);
dataGridView1.RowCount = n + 1;

dataGridView1.ColumnCount = m + 1;
for (int i = 0; i < n + 1; i++)

{

for (int j = 0; j < m + 1; j++)

{

dataGridView1.Rows[i].Cells[j].Value = u[i, j].ToString();

}

}

chart1.Series.Clear();

string l = "";

for (int j = 1; j < 10; j += 2)

{

l = "t=" + Math.Round(t[j], 3).ToString();

chart1.Series.Add(l);

for (int i = 0; i < n + 1; i++)

{

chart1.Series[l].Points.AddXY(x[i], u[i, j]);

}

chart1.Series[l].ChartType = SeriesChartType.Spline;

}
}

else MessageBox.Show("sigmaga musbat qiymat bering");

}
private double u0x(double[] x, double sigma)

{

throw new NotImplementedException();

}
private double u0x(double x, double sigma)

{

throw new NotImplementedException();

}
private void Form1_Load(object sender, EventArgs e)

{
}
}

}
Download 17.71 Kb.

Do'stlaringiz bilan baham:




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling