public double[,] GetPointMatrixH(Jacobian jacobian, double conductivity) { double[] dndx = jacobian.GetdNdx(); double[] dndy = jacobian.GetdNdy(); double det = jacobian.GetDetJ(); double[,] tmpdndx = MatrixOperations.multiply(dndx, MatrixOperations.transpose(dndx), det); double[,] tmpdndy = MatrixOperations.multiply(dndy, MatrixOperations.transpose(dndy), det); return(MatrixOperations.multiply(MatrixOperations.addition(tmpdndx, tmpdndy), new double[] { conductivity })); }
public double[,] GetSurfaceMatrixH(int surfaceID, double alfa) { IntPoint pkt1 = new IntPoint(-1 / Math.Sqrt(3)); IntPoint pkt2 = new IntPoint(1 / Math.Sqrt(3)); double[,] pcMatrix1 = pkt1.GetPcMatrix(alfa); double[,] pcMatrix2 = pkt2.GetPcMatrix(alfa); double det = this.GetSurfaceLength(surfaceID) / 2; return(MatrixOperations.multiply(MatrixOperations.addition(pcMatrix1, pcMatrix2), new double[] { det })); }
public double[] GetSurfaceVectorP(int surfaceID, double alfa, double ambientTemperature) { IntPoint pkt1 = new IntPoint(-1 / Math.Sqrt(3)); IntPoint pkt2 = new IntPoint(1 / Math.Sqrt(3)); double[] n1 = pkt1.GetNVector(); double[] n2 = pkt2.GetNVector(); double det = this.GetSurfaceLength(surfaceID) / 2; return(MatrixOperations.multiply(MatrixOperations.addition(n1, n2), new double[] { alfa, ambientTemperature, det })); }
private void buildMeshButton_Click(object sender, EventArgs e) { double initTemp = double.Parse(initTempBox.Text.Replace('.', ',')); double symTime = double.Parse(symTimeBox.Text.Replace('.', ',')); double symStepTime = double.Parse(symStepTimeBox.Text.Replace('.', ',')); double ambientTemp = double.Parse(ambientTempBox.Text.Replace('.', ',')); double alpha = double.Parse(alphaBox.Text.Replace('.', ',')); double H = double.Parse(hBox.Text.Replace('.', ',')); double B = double.Parse(bBox.Text.Replace('.', ',')); int nH = int.Parse(nHBox.Text); int nB = int.Parse(nBBox.Text); double specHeat = double.Parse(specHeatBox.Text.Replace('.', ',')); double conductivity = double.Parse(conductivityBox.Text.Replace('.', ',')); double density = double.Parse(densityBox.Text.Replace('.', ',')); this.globalData = new GlobalData(initTemp, symTime, symStepTime, ambientTemp, alpha, H, B, nH, nB, specHeat, conductivity, density); grid = new Grid(globalData); UniversalElement[] universalElements = UniversalElement.CreateUniversalElements(); int nodeNumber = globalData.GetNumberOfNodes(); c = new double[nodeNumber, nodeNumber]; h = new double[nodeNumber, nodeNumber]; p = new double[nodeNumber]; foreach (Element element in grid.GetElements()) { int elementNodeNumber = element.GetNodes().Length; double[,] elementH = new double[elementNodeNumber, elementNodeNumber]; double[,] elementC = new double[elementNodeNumber, elementNodeNumber]; double[] elementP; foreach (UniversalElement universalElement in universalElements) { Jacobian jacobian = new Jacobian(element, universalElement); elementH = MatrixOperations.addition(elementH, element.GetPointMatrixH(jacobian, globalData.GetConductivity())); elementC = MatrixOperations.addition(elementC, element.GetPointMatrixC(universalElement, jacobian.GetDetJ(), globalData.GetSpecificHeat(), globalData.GetDensity())); } elementH = MatrixOperations.addition(elementH, element.GetMatrixHbc(globalData.GetAlfa())); elementP = element.getVectorP(globalData.GetAlfa(), globalData.GetAmbientTemp()); Node[] nodes = element.GetNodes(); for (int i = 0; i < nodes.Length; i++) { for (int j = 0; j < nodes.Length; j++) { c[nodes[i].GetId() - 1, nodes[j].GetId() - 1] += elementC[i, j]; h[nodes[i].GetId() - 1, nodes[j].GetId() - 1] += elementH[i, j]; } p[nodes[i].GetId() - 1] += elementP[i]; } } }
private void simulateButton_Click_1(object sender, EventArgs e) { results.Text = ""; double[,] resultH; double[] resultP; for (int time = 0; time < globalData.GetSymTime(); time += (int)globalData.GetStepTime()) { double[] t0 = grid.GetTemperatures(); resultP = MatrixOperations.addition(p, MatrixOperations.multiply(c, t0, 1 / globalData.GetStepTime())); resultH = MatrixOperations.addition(h, MatrixOperations.multiply(c, new double[] { 1 / globalData.GetStepTime() })); t0 = MatrixOperations.gaussianElimination(resultH, resultP); grid.SetTemperatures(t0); results.Text += "Time[s]: " + (time + globalData.GetStepTime()) + "\t\tMinTemperature [°C]: " + min(t0) + "\t\tMaxTemperature [°C]: " + max(t0) + "\n"; Console.WriteLine("Time[s]: " + (time + globalData.GetStepTime()) + "\t\tMinTemperature [°C]: " + min(t0) + "\t\tMaxTemperature [°C]: " + max(t0) + "\n"); } }
public Jacobian(Element element, UniversalElement universalElement) { double[,] tab = new double[2, 2]; for (int i = 0; i < element.GetNodes().Length; i++) { tab[0, 0] += universalElement.GetdKsi(i) * element.GetNode(i).GetX(); tab[0, 1] += universalElement.GetdKsi(i) * element.GetNode(i).GetY(); tab[1, 0] += universalElement.GetdEta(i) * element.GetNode(i).GetX(); tab[1, 1] += universalElement.GetdEta(i) * element.GetNode(i).GetY(); } det = MatrixOperations.determinant(tab); inverseJacobian = MatrixOperations.inverse(tab); dNdx = new double[4]; dNdy = new double[4]; for (int i = 0; i < 4; i++) { dNdx[i] = GetInverseJacobian()[0, 0] * universalElement.GetdKsi(i) - GetInverseJacobian()[0, 1] * universalElement.GetdEta(i); dNdy[i] = -GetInverseJacobian()[1, 0] * universalElement.GetdKsi(i) + GetInverseJacobian()[1, 1] * universalElement.GetdEta(i); } }
public double[,] GetPointMatrixC(UniversalElement universalElement, double det, double specificHeat, double density) { double[] shapeFunctions = universalElement.GetShapeFun(); return(MatrixOperations.multiply(shapeFunctions, MatrixOperations.transpose(shapeFunctions), det * specificHeat * density)); }
public double[,] GetPcMatrix(double alfa) { double[] n = GetNVector(); return(MatrixOperations.multiply(n, MatrixOperations.transpose(n), alfa)); }