public void calculate(int n, double c, room target_room, int num_iter,system_output DGV) { double[,] new_temperature = new double[target_room.rows ,target_room.cols]; double delta_s=1/(float)(n+1); double delta_t= (delta_s*delta_s) / (4*c); DGV.after.ColumnCount = target_room.cols; DGV.after.RowCount = target_room.rows; for(int i = 0 ; i <num_iter ; i++) { new_temperature = new double[target_room.rows, target_room.cols]; for (int j = 0; j < target_room.rows; j++) { for (int k = 0; k < target_room.cols; k++) { if (j == 0) new_temperature[j, k] = target_room.Degree[j, k]; else if (j == target_room.rows - 1) new_temperature[j, k] = target_room.Degree[j, k]; else if (k == 0) new_temperature[j, k] = target_room.Degree[j, k]; else if (k == target_room.cols - 1) new_temperature[j, k] = target_room.Degree[j, k]; else new_temperature[j, k] = target_room.Degree[j, k] + (c * (delta_t / Math.Pow(delta_s, 2))) * (target_room.Degree[j + 1, k] + target_room.Degree[j - 1, k] - 4 * target_room.Degree[j, k] + target_room.Degree[j, k + 1] + target_room.Degree[j, k - 1]); if(i==num_iter-1) DGV.after.Rows[j].Cells[k].Value = new_temperature[j, k]; } } target_room.Degree = new_temperature; } }
public static void call_seq() { DGV = new system_output(); temperature_room = new room(rows, cols); temperature_room = temperature_room.intialize_room(initial_temperature, left_side, right_side, bottom_side, top_side,DGV); sequential = new sequential_solution(); sequential.calculate(rows, biot_numer, temperature_room, iteration_number,DGV); DGV.Show(); }
public room intialize_room(double initial_temperature, double left_side, double right_side, double bottom_side, double top_side,system_output DGV) { DGV.before.ColumnCount = cols; DGV.before.RowCount = rows; for (int j = 0; j < rows; j++) for (int k = 0; k < cols; k++) { if (j == 0) Degree[j, k] = top_side; else if (j == rows - 1) Degree[j, k] = bottom_side; else if (k == 0) Degree[j, k] = left_side; else if (k == cols - 1) Degree[j, k] = right_side; else Degree[j, k] = initial_temperature; DGV.before.Rows[j].Cells[k].Value = Degree[j, k]; } return this; }