Código:
Código
//New_problem_1 #include<iostream> #include<vector> using namespace std; const double rho1=1500.0, rho2=1600.0, rho3=1900.0, rho4=2500.0; //densities(kg/m3) const double cp1=750.0, cp2=770.0, cp3=810.0, cp4=930.0; //cp (J/kg*K) const double k1=170.0, k2=140.0, k3=200.0, k4=140.0; //thermic_conductivity (W/m*K) const double alpha=9.0, Tg=33+273; //heat_transfer_coefficient_and_temperature_of_external_gas const double q_top=60.0; //Q_flow_on_the_top_considered_outgoing double k12=0.0, k13=0.0, k32=0.0, k24=0.0, k34=0.0; //heat_transfer_coefficients_internal_borders const double t_step=1.0; //time_discretitzation const double L=1.1, H=0.8; //geometric_definition const double T0=281.0; //initial_temperature const int Nx=11, Ny=8; //control_volumes_(horitzontal_vertical) const double Ax=L/Nx, Ay=H/Ny; //nodes_separation int main(){ vector<double> Xnode(Nx+1,0.0), Ynode(Ny+1,0.0); //nodes_position_vectors vector<vector<double> > T_bef_calc(Nx+1,vector<double>(Ny+1,0.0)); //T(n)_calculated vector<vector<double> > T_now_est(Nx+1,vector<double>(Ny+1,0.0)); //T(n+1)_estimated vector<vector<double> > T_now_calc(Nx+1,vector<double>(Ny+1,0.0)); //T(n+1)_calculated //geometric_definition Xnode[0]=0; Xnode[1]=Ax/2; Xnode[Nx+1]=L; for (int i=2;i<=Nx+1;i++){ Xnode[i]=Xnode[i-1]+Ax; } Ynode[0]=0; Ynode[1]=Ay/2; Ynode[Ny+1]=H; for (int i=2;i<=Ny+1;i++){ Ynode[i]=Ynode[i-1]+Ay; } //Initialitzation_of_temperatures for (int i=0;i<=1;i++){ for (int j=0; j<=1; j++){ T_bef_calc[i][j]=T0; } } return 0; }
Mod: Los códigos deben ir en etiquetas GeSHi