Difference between revisions of "Mekanika Fluida - Josiah Enrico S (1906356286)"

From ccitonlinewiki
Jump to: navigation, search
(Methodology)
(Methodology)
Line 14: Line 14:
 
|-
 
|-
 
|
 
|
model Tugas_Besar_Mekflu
+
model Tugas_Besar_Mekflu
 
+
// ==================================== DEFINITION PHASE ====================================
+
// ==================================== DEFINITION PHASE ====================================
 
+
parameter Real miu = 0.3 "dynamic viscosity";
+
parameter Real miu = 0.3 "dynamic viscosity";
parameter Real rho = 900 "density";
+
parameter Real rho = 900 "density";
 
+
parameter Real Qinlet = 5e-4 "flow rate inlet";
+
parameter Real Qinlet = 5e-4 "flow rate inlet";
parameter Real Pinlet = 39182 "pressure inlet";
+
parameter Real Pinlet = 39182 "pressure inlet";
parameter Real Poutlet = -3665 "pressure inlet";
+
parameter Real Poutlet = -3665 "pressure inlet";
parameter Integer boundary[:] = {1, 6} "Boundary Point";
+
parameter Integer boundary[:] = {1, 6} "Boundary Point";
 
+
parameter Integer nPipe = 6 "number of piping";
+
parameter Integer nPipe = 6 "number of piping";
parameter Integer nPoint = 6 "number of point connected";
+
parameter Integer nPoint = 6 "number of point connected";
final constant Real pi=2*Modelica.Math.asin(1.0);
+
final constant Real pi=2*Modelica.Math.asin(1.0);
 
+
//Inputing pipe connection, length (L) and diameter (D)
+
//Inputing pipe connection, length (L) and diameter (D)
parameter Real data[nPipe,2] = [ 70.71, 0.1  ;
+
parameter Real data[nPipe,2] = [ 70.71, 0.1  ;
                                50.99, 0.075 ;
+
                                  50.99, 0.075 ;
                                50  , 0.075 ;
+
                                  50  , 0.075 ;
                                53.85, 0.05  ;
+
                                  53.85, 0.05  ;
                                70.71, 0.05  ;
+
                                  70.71, 0.05  ;
                                60  , 0.1  ];
+
                                  60  , 0.1  ];
                               
+
parameter Integer no[nPoint,2] = [ 1, 2;
+
parameter Integer no[nPoint,2] = [ 1, 2;
                                  2, 3;
+
                                    2, 3;
                                  2, 4;
+
                                    2, 4;
                                  3, 5;
+
                                    3, 5;
                                  4, 5;
+
                                    4, 5;
                                  5, 6];
+
                                    5, 6];
 
+
//Solution
+
//Solution
Real Pressure[nPoint], Flowrate[nPipe], Reynolds[nPipe];                           
+
Real Pressure[nPoint], Flowrate[nPipe], Reynolds[nPipe];                           
 
+
protected
+
protected
Real g[nPoint,nPoint], G[nPoint,nPoint], id[nPoint,nPoint]=identity(nPoint), P[nPoint], Res;
+
Real g[nPoint,nPoint], G[nPoint,nPoint], id[nPoint,nPoint]=identity(nPoint), P[nPoint], Res;
     
+
       
// ==================================== SOLUTION PHASE ====================================
+
// ==================================== SOLUTION PHASE ====================================
                               
+
                                 
algorithm
+
algorithm
//Iterating to create global matrice
+
//Iterating to create global matrice
for i in 1:nPipe loop
+
for i in 1:nPipe loop
  Res:= pi*data[i,2]^4/(128*data[i,1]*miu);
+
  Res:= pi*data[i,2]^4/(128*data[i,1]*miu);
 +
 
 +
  g:=zeros(nPoint,nPoint);         
 +
  g[no[i,1],no[i,1]]:= Res;
 +
  g[no[i,1],no[i,2]]:= -Res;
 +
  g[no[i,2],no[i,1]]:= -Res;
 +
  g[no[i,2],no[i,2]]:= Res;
 
    
 
    
  g:=zeros(nPoint,nPoint);         
+
  G:= G+g;
  g[no[i,1],no[i,1]]:= Res;
+
end for;
  g[no[i,1],no[i,2]]:= -Res;
+
  g[no[i,2],no[i,1]]:= -Res;
+
//Implementing boundary
  g[no[i,2],no[i,2]]:= Res;
+
for i in boundary loop
 
+
  for j in 1:nPoint loop
  G:= G+g;
+
    G[i,j]:= id[i,j];
end for;
+
  end for;
 
+
end for;
//Implementing boundary
+
for i in boundary loop
+
//Solving pressure in each point connected
  for j in 1:nPoint loop
+
P[boundary[1]]:= Pinlet;
    G[i,j]:= id[i,j];
+
P[boundary[2]]:= Poutlet;
  end for;
+
Pressure:= Modelica.Math.Matrices.solve(G,P);
end for;
+
 
+
//Solving flowrate in each pipe
//Solving pressure in each point connected
+
for i in 1:nPipe loop
P[boundary[1]]:= Pinlet;
+
  Flowrate[i]:= pi*data[i,2]^4/(128*data[i,1]*miu)*(Pressure[no[i,1]]-Pressure[no[i,2]]);
P[boundary[2]]:= Poutlet;
+
end for;
Pressure:= Modelica.Math.Matrices.solve(G,P);
+
 
+
//Solving Reynolds Number in each pipe flow
//Solving flowrate in each pipe
+
for i in 1:nPipe loop
for i in 1:nPipe loop
+
  Reynolds[i]:= 4*rho*Flowrate[i]/(pi*miu*data[i,2]);
  Flowrate[i]:= pi*data[i,2]^4/(128*data[i,1]*miu)*(Pressure[no[i,1]]-Pressure[no[i,2]]);
+
end for;
end for;
+
 
+
end Tugas_Besar_Mekflu;
//Solving Reynolds Number in each pipe flow
 
for i in 1:nPipe loop
 
  Reynolds[i]:= 4*rho*Flowrate[i]/(pi*miu*data[i,2]);
 
end for;
 
 
 
end Tugas_Besar_Mekflu;
 
 
|}
 
|}
  

Revision as of 23:20, 6 June 2021

Title: Modelica-based Simulation of Viscous Flow Through Pipes Using Finite Element Formulation

Abstract

Introduction

Objectives

Methodology

model Tugas_Besar_Mekflu

// ==================================== DEFINITION PHASE ====================================

parameter Real miu = 0.3 "dynamic viscosity";
parameter Real rho = 900 "density";

parameter Real Qinlet = 5e-4 "flow rate inlet";
parameter Real Pinlet = 39182 "pressure inlet";
parameter Real Poutlet = -3665 "pressure inlet";
parameter Integer boundary[:] = {1, 6} "Boundary Point";

parameter Integer nPipe = 6 "number of piping";
parameter Integer nPoint = 6 "number of point connected";
final constant Real pi=2*Modelica.Math.asin(1.0);

//Inputing pipe connection, length (L) and diameter (D)
parameter Real data[nPipe,2] = [ 70.71, 0.1   ;
                                 50.99, 0.075 ;
                                 50   , 0.075 ;
                                 53.85, 0.05  ;
                                 70.71, 0.05  ;
                                 60   , 0.1   ];

parameter Integer no[nPoint,2] = [ 1, 2;
                                   2, 3;
                                   2, 4;
                                   3, 5;
                                   4, 5;
                                   5, 6];

//Solution
Real Pressure[nPoint], Flowrate[nPipe], Reynolds[nPipe];                          

protected
Real g[nPoint,nPoint], G[nPoint,nPoint], id[nPoint,nPoint]=identity(nPoint), P[nPoint], Res;
       
// ==================================== SOLUTION PHASE ====================================
                                 
algorithm
//Iterating to create global matrice
for i in 1:nPipe loop
  Res:= pi*data[i,2]^4/(128*data[i,1]*miu);
  
  g:=zeros(nPoint,nPoint);          
  g[no[i,1],no[i,1]]:= Res;
  g[no[i,1],no[i,2]]:= -Res; 
  g[no[i,2],no[i,1]]:= -Res; 
  g[no[i,2],no[i,2]]:= Res;
 
  G:= G+g;
end for;

//Implementing boundary
for i in boundary loop
  for j in 1:nPoint loop
    G[i,j]:= id[i,j];
  end for;
end for;

//Solving pressure in each point connected
P[boundary[1]]:= Pinlet;
P[boundary[2]]:= Poutlet;
Pressure:= Modelica.Math.Matrices.solve(G,P);

//Solving flowrate in each pipe
for i in 1:nPipe loop
  Flowrate[i]:= pi*data[i,2]^4/(128*data[i,1]*miu)*(Pressure[no[i,1]]-Pressure[no[i,2]]);
end for;

//Solving Reynolds Number in each pipe flow
for i in 1:nPipe loop
  Reynolds[i]:= 4*rho*Flowrate[i]/(pi*miu*data[i,2]);
end for;

end Tugas_Besar_Mekflu;

Result and Analysis

Conclusions

Acknowledgement

References