Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register
  • Index
  • » Users
  • » krishnakqted
  • » Profile

Posts

Posts

Feb-12-14 12:42:12
Category: Programming

Hiiii

I have a problem!
This code is to solve differential equation ! wen i try to run i get error abt flattening !
I have no clue ! wat to change!

model try1  "Solve the differential equation involving the matrices"
  extends Modelica.Math;
  extends Modelica.SIunits;
  parameter SI.Pressure Intake_Pressure = 100000 "The pressure of air at the intake";
  parameter SI.Temperature Intake_Temperature = 298 "The temperature of air entering";
  parameter SI.Temperature Wall_Temperature = 310 "The temperature at the pipe wall";
  parameter SI.Denstiy Intake_Density = 1.186 "Density of the air entering";
  parameter SI.Velocity Intake_Velocity = 346 "The local velocity of air entering";
  parameter SI.Length Intake_Dia = 0.041 "The diameter of the intake pipe";
  parameter SI.Length Intake_length = 1 "The length of the intake pipe";
  parameter SI.Density Exit_Density = 1.2 "The density of air exiting ,could be into cylinder or atm";
  parameter SI.Temperature Exit_Temperature = 340 "The exit temperature of the gas";
  parameter Real no_of_vol = 5;
  SI.Area Intake_area_pipe;
  SI.MassFlowRate Intake_mfr;
  SI.MassFlowRate Exit_mfr;
  SI.InternalEnergy Stag_IntEnergy;
  SI.Enthalpy Stag_Enthaly;
  Real k_cylinder;
  Real h_convection;
  Real f_pipe;
  Real z;
  Real dl;
  Real A1[3,3] = {{1,0,0},{0,dl,0},{0,0,1}};
  Real A2[3,3] = {{dl,0,0},{0,dl,0},{0,0,dl}};
  Real B[6,6,3,3];
  Real Alpha[6,6];
  Real Beta[6,6];
  Real Delta[6,6];
  Real W[3,1];
  Real Rhs[3,1];
equation
  Intake_area_pipe = pi / 4 * Intake_dia ^ 2;
  Intake_mfr = Intake_Density * Intake_area_pipe * Intkae_Velocity;
  for i in 1:6 loop
  for k in 1:6 loop
  for j in 0.5:5.5 loop
  dl = Intake_length / no_of_vol;
  W = {Alpha(1, i),Beta(1, j),Delta(1, i)};
  z = i * k;
  if z == 1 and z == 36 then
    B[i,k] = A1;
  elseif i == k then
    B[i,k] = A2;
  else
    B[i,k] = zeros(3, 3);
  end if;
  Alpha(1, 1) = 1.186;
  ALpha(1, 6) = 1.204;
  Beta(0, -0.5) = 20;
  Beta(0, 5.5) = 28;
  Delta(1, 1) = 718 * Alpha(1, 1) * Intake_Temperature + (0.5 * Beta(0.0 - 0.5) ^ 2) / Alpha(1, 1) * Intake_area_pipe;
  Delta(1, 6) = 718 * ALpha(1, 6) * Exit_Temperature + (0.5 * Beta(0, 5.5) ^ 2) / Alpha(1, 6) * Intake_area_pipe;
  Rhs = {Beta(1, j - 1) - Beta(1, j),0.4 * Intake_are_pipe * ({Alpha(1, i) * Delta(1, i)} - {Alpha(1, i + 1) * Delta(1, i + 1)}) - 0.8 * ({Beta(1, j) ^ 2 / Alpha(1, i + 1)} - {Beta(1, j - 1) ^ 2 / Alpha(1, i)}),1.4 * ({Beta(1, j) * Delta(1, i)} - {Beta(1, j - 1) * Delta(1, i - 1)}) - 0.2 / Intake_area_pipe ^ 2 * ({Beta(1, j) ^ 3 / Alpha(1, i) ^ 2} - {Beta(1, j - 1) ^ 3 / Alpha(1, i - 1) ^ 2})};
  B * der(W) = Rhs;

  end for;

  end for;

  end for;
  //The loop for alpha and delta//
  //This im considering because i need two loops running from 1 to n to obtain the Wc diagonal matrix//
  //The loop for Beta//
  //This im using to define the two if condition those are BCL(i,k=1) n BCR(i,k=6)//
  //Implementing if condition fro BCL n BCR//
  //BCL,BCR//
  //The diagonal matrix for intermediate volumes//
  //All other elements are zero//
  //Initial value of the density,these are not exact mostly assumed//
  //Final value of density//
  //Massflowrate of air enterning pipe,exp data//
  //Massflowrate of air into the cylinder//
  //initial values of delta//
  //Final values of delta//
end try1;

kindly hlep
Thanks

Feb-12-14 12:38:41
Category: Programming

Hiii


Im beginner to modelica.
Basically this code is to solve the derivative equation ( the variables involved are matrices)
I get this error! I don understand wat to do

model try1
  extends Modelica.Math;
  extends Modelica.SIunits;
  parameter SI.Pressure Intake_Pressure = 100000 "The pressure of air at the intake";
  parameter SI.Temperature Intake_Temperature = 298 "The temperature of air entering";
  parameter SI.Temperature Wall_Temperature = 310 "The temperature at the pipe wall";
  parameter SI.Denstiy Intake_Density = 1.186 "Density of the air entering";
  parameter SI.Velocity Intake_Velocity = 346 "The local velocity of air entering";
  parameter SI.Length Intake_Dia = 0.041 "The diameter of the intake pipe";
  parameter SI.Length Intake_length = 1 "The length of the intake pipe";
  parameter SI.Density Exit_Density = 1.2 "The density of air exiting ,could be into cylinder or atm";
  parameter SI.Temperature Exit_Temperature = 340 "The exit temperature of the gas";
  parameter Real no_of_vol = 5;
  SI.Area Intake_area_pipe;
  SI.MassFlowRate Intake_mfr;
  SI.MassFlowRate Exit_mfr;
  SI.InternalEnergy Stag_IntEnergy;
  SI.Enthalpy Stag_Enthaly;
  Real k_cylinder;
  Real h_convection;
  Real f_pipe;
  Real z;
  Real dl;
  Real A1[3,3] = {{1,0,0},{0,dl,0},{0,0,1}};
  Real A2[3,3] = {{dl,0,0},{0,dl,0},{0,0,dl}};
  Real B[6,6,3,3];
  Real Alpha[6,6];
  Real Beta[6,6];
  Real Delta[6,6];
  Real W[3,1];
  Real Rhs[3,1];
equation
  Intake_area_pipe = pi / 4 * Intake_dia ^ 2;
  Intake_mfr = Intake_Density * Intake_area_pipe * Intkae_Velocity;
  for i in 1:6 loop
  for k in 1:6 loop
  for j in 0.5:5.5 loop
  dl = Intake_length / no_of_vol;
  W = {Alpha(1, i),Beta(1, j),Delta(1, i)};
  z = i * k;
  if z == 1 and z == 36 then
    B[i,k] = A1;
  elseif i == k then
    B[i,k] = A2;
  else
    B[i,k] = zeros(3, 3);
  end if;
  Alpha(1, 1) = 1.186;
  ALpha(1, 6) = 1.204;
  Beta(0, -0.5) = 20;
  Beta(0, 5.5) = 28;
  Delta(1, 1) = 718 * Alpha(1, 1) * Intake_Temperature + (0.5 * Beta(0.0 - 0.5) ^ 2) / Alpha(1, 1) * Intake_area_pipe;
  Delta(1, 6) = 718 * ALpha(1, 6) * Exit_Temperature + (0.5 * Beta(0, 5.5) ^ 2) / Alpha(1, 6) * Intake_area_pipe;
  Rhs = {Beta(1, j - 1) - Beta(1, j),0.4 * Intake_are_pipe * ({Alpha(1, i) * Delta(1, i)} - {Alpha(1, i + 1) * Delta(1, i + 1)}) - 0.8 * ({Beta(1, j) ^ 2 / Alpha(1, i + 1)} - {Beta(1, j - 1) ^ 2 / Alpha(1, i)}),1.4 * ({Beta(1, j) * Delta(1, i)} - {Beta(1, j - 1) * Delta(1, i - 1)}) - 0.2 / Intake_area_pipe ^ 2 * ({Beta(1, j) ^ 3 / Alpha(1, i) ^ 2} - {Beta(1, j - 1) ^ 3 / Alpha(1, i - 1) ^ 2})};
  B * der(W) = Rhs;

  end for;

  end for;

  end for;
  end try1;

Kindly help!
Thanks

Feb-07-14 09:17:13
Category: Programming

Hii

I have a package of interfaces already created.
I want to add a new connector to this package, How should it be done??

Kindly help

Thanks

Feb-06-14 13:56:52
Category: Programming

Hiii

Can i define a variable an an input and then use it in the equation
the equation is a ordinary differential equation?

It will be good if u can give me an example!

Thanks

Hiii

Im trying to connect the pipe to the boundary (Boundary_ph) im getting a dailog box which asks me to enter a valid positive number.
I enter 1 and the connection fails!
How is this supposed to be done!!

Thanks a lot!

Feb-04-14 12:53:07
Category: Programming

hii

Im trying to connect dynamic pipe through a valve to another dynamic pipe in omedit!
i get these errors


Translation    15:21:33    /usr/lib/omlibrary/Modelica 3.2.1/Fluid/Interfaces.mo    223:5-223:64    No corresponding 'inner' declaration found for component .Modelica.Fluid.System pipe.system declared as 'outer '.
  The existing 'inner' components are:
    There are no 'inner' components defined in the model in any of the parent scopes of 'outer' component's scope: Modelica.Fluid.Pipes.DynamicPipe.
  Check if you have not misspelled the 'outer' component name.
  Please declare an 'inner' component with the same name in the top scope.
  Continuing flattening by only considering the 'outer' component declaration.
Translation    15:21:33        0:0-0:0    Error building simulator. Buildlog: gcc -I"/usr/include/omc"  -O0 -falign-functions -march=native -mfpmath=sse -fPIC  -c -o Modelica_Fluid_Interfaces_FluidPort__b_Medium_specificEnthalpy__pTX.o Modelica_Fluid_Interfaces_FluidPort__b_Medium_specificEnthalpy__pTX.c
Modelica_Fluid_Interfaces_FluidPort__b_Medium_specificEnthalpy__pTX.c: In function 'omc_Modelica_Fluid_Interfaces_FluidPort__b_Medium_specificEnthalpy__pTX':
Modelica_Fluid_Interfaces_FluidPort__b_Medium_specificEnthalpy__pTX.c:17:3: error: unknown type name 'Modelica_Fluid_Interfaces_FluidPort__b_Medium_setState__pTX_rettype'
Modelica_Fluid_Interfaces_FluidPort__b_Medium_specificEnthalpy__pTX.c:18:3: error: unknown type name 'Modelica_Fluid_Interfaces_FluidPort__b_Medium_specificEnthalpy_rettype'
Modelica_Fluid_Interfaces_FluidPort__b_Medium_specificEnthalpy__pTX.c:26:81: error: request for member 'c1' in something not a structure or union
Modelica_Fluid_Interfaces_FluidPort__b_Medium_specificEnthalpy__pTX.c:27:12: error: request for member 'c1' in something not a structure or union
make: *** [Modelica_Fluid_Interfaces_FluidPort__b_Medium_specificEnthalpy__pTX] Error 1

I have absolutely no clue what my mistake is!

Can anyone help!

Thanks

Feb-04-14 08:14:36
Category: Programming

Hiii

Can you please guide me,
I want to build a model which will be simulating the flow of air in a venturi using the Modelica.Fluid library!
I tried a lot ! I built a model with pipes n sharp edged orifices(for venturi) but its not correct !
I Dont know what components to use? Do i need a source? do i need to use dynamics pipe instead of striaght pipe?
How to model venturi? are there specific options in omedit under fluids?

Thanks a lot

Krishna

Feb-04-14 08:12:51
Category: Programming

Hiii

Can you please guide me,
I want to build a model which will be simulating the flow of air from egr  to intake manifold using the Modelica.Fluid library!
I tried a lot ! I built a model with pipes n sharp edged orifices(for venturi) but its not correct !
I Dont know what components to use? Do i need a source? do i need to use dynamics pipe instead of striaght pipe?
How to model venturi? are there specific options in omedit under fluids?

Kindly help

Thanks a lot
krishna

Jan-30-14 11:00:11
Category: Programming

Hiii

This question is not on the coding side! building flow model using Modelica.Fluid library(package).
I want to model air flow in egr! i.e exhaust gases will enter intake manifold through valve!
I Read about the options and components availble in the modelica fluid library.

I did not understand much!

Thanks
krishna

Hii

I wanted to use the modelica fluid library and simulate exhaust air flow into intake manifold( basically modelling flow in egr)!
How can i do it in omedit? do i need to use dynamic pipe? how to give boundary conditions?

Thanks

Jan-29-14 14:07:42
Category: Programming

Hiii

Thank you! This is extremely helpfull !!

thanks

krishna

Jan-29-14 10:39:39
Category: Programming

Hiii

Yup i understand now that its not a 3D array but a 4D array!! it will be a 10 by 10 matrix with 3 by 3 as its elements arranged diagonally and other elements zero!!


model fourD
  Real A[3,3]={{1,0,0},{0,10,0},{0,0,1}}; //This is the matrix which will be the elements of the 4D array//
input  Real B[:,:,:,:];   //4D arrray//
equation
for i in 1:10 loop
for j in 1:10 loop
for k in 1:10 loop
for l in 1:10 loop

if j=k
Real B[i,j,k,l]=A[3,3]  // this line makes sure that only daigonal elements of 4D array are assigned by A//
else
Real B[i,j,k,l]=0;     // All other elements are zero//
end for;
end for;
end for;
end for;
end fourD;


Can u please take a look at this code!

error is
Syntax    12:59:12        10:5-10:5    Parser error: Unexpected token near: = (EQUALS)

thanks a lot

krishna

Jan-28-14 14:45:02
Category: Programming

Hiii

Hmmm

the matrix (n by n) is a 2D matrix with its elements as numbers (eg  A[3,3]={{1,2,3},{4,5,6},{7,8,9}} )
now say 10 of these A[3,3] have been arranged diagonally   (all other elements zero) to give a matrix  !! this cud be called a( 3D array)!!
I hope im clear now !!

thanks a lot

Jan-28-14 14:07:17
Category: Programming

hii

thanks a lot ! moving the equation above helped!

3D array is not general one!
i want to use this 3D array in a for loop!! where i can change the first dimension to 10 or 20 but the elements will be matrices of 3by 3!
important thing is the diagonal elements are 3 by 3 matrix other elements are all zero

i hope u understand my question

Thanks again!

Jan-28-14 13:58:53
Category: Programming

Hiii

Can u also help me with another doubt!

I wanted to define 3D array which contains block matrices of 3 by 3!!

thanks a lot

Jan-28-14 13:56:00
Category: Programming

hii

i tried with equation also

model prog
parameter Real rho =1.1839;
parameter Real dia = 0.08;
parameter Real Temp = 298;
parameter Real Cv = 718; 
Real area_of_intake= 3.14*0.04*0.04/4;
Real Alpha[:,:];
Real Beta[:,:]; 
Real Delta[:,:];
for i in 1:10 loop
for j in 2:10 loop
equation
Alpha[1,1]= 1.1839;
Delta[1,1]= 1.1839*Cv*298+0.5*Beta[1,1]/area_of_intake^2*1.1839;
Alpha[10,1]= 1.1839;
Delta[10,1]= 1.1839*Cv*298+0.5*Beta[10,j]/area_of_intake^2*1.1839;
der(Alpha[i,j])= Beta[i,j-1]-Beta[i,j];
der(Beta[i,j])= 0.4*area_of_intake^2*(Alpha[i,j]*Delta[i,j]-Alpha[i,j+1]*Delta[i,j+1])-0.8*(Beta[i,j]/Alpha[i,j]-Beta[i,j+1]/Alpha[i,j+1]);
der(Delta[i,j])= 1.4*(Beta[i,j+1]*Delta[i,j+1]/Alpha[i,j+1] - Beta[i,j+2]*Delta[i,j+2]/Alpha[i,j+2]);
end for;
end for;
end prog;



it does not work even with that same error!

Jan-28-14 13:16:12
Category: Programming

Hiii

I wanted to write equations in for loop! the code i have written is following

model prog
parameter Real rho =1.1839;
parameter Real dia = 0.08;
parameter Real Temp = 298;
parameter Real Cv = 718;
Real area_of_intake= 3.14*0.04*0.04/4;
Real Alpha[:,:];
Real Beta[:,:];
Real Delta[:,:];
for i in 1:10 loop
for j in 2:10 loop
Alpha[1,1]= 1.1839;
Delta[1,1]= 1.1839*Cv*298+0.5*Beta[1,1]/area_of_intake^2*1.1839;
Alpha[10,1]= 1.1839;
Delta[10,1]= 1.1839*Cv*298+0.5*Beta[10,j]/area_of_intake^2*1.1839;
der(Alpha[i,j])= Beta[i,j-1]-Beta[i,j];
der(Beta[i,j])= 0.4*area_of_intake^2*(Alpha[i,j]*Delta[i,j]-Alpha[i,j+1]*Delta[i,j+1])-0.8*(Beta[i,j]/Alpha[i,j]-Beta[i,j+1]/Alpha[i,j+1]);
der(Delta[i,j]= 1.4*(Beta[i,j+1]*Delta[i,j+1]/Alpha[i,j+1] - Beta[i,j+2]*Delta[i,j+2]/Alpha[i,j+2]);
end for;
end for;
end prog;

The model does not compile and gives error

Syntax    15:41:02        10:1-10:4    No viable alternative near token: for

Thanks for your help!!

Jan-27-14 14:18:48
Category: Programming

Hiii

Im a new to open modelica!

I want to know how to define a 3 dimensional matrix ?? (i.e the elements of the matrix themself are block diagonal matrices of 3 by 3)

Thnaks in advance

  • Index
  • » Users
  • » krishnakqted
  • » Profile
You are here: