Opened 4 years ago

Last modified 3 years ago

#6385 assigned defect

Overdetermined system

Reported by: anonymous Owned by: Shravya Hebbur Murali <shravya2535@…>
Priority: high Milestone:
Component: OMEdit Version: 1.16.2
Keywords: Overdetermined, openmodelicabeginner, nanofiltration Cc: Andreas Heuermann, Philip Hannebohm

Description

Does anyone have a system for how they determine where the errors are in their overdetermined model? I find that the errors from the simulation do not directly lead me to the error

package SplitM_1

connector Inlet


flow Real Q[17] (each quantity="volumetric flowrate", each unit="L/h") "Flowrate";
input Real c[17] (each quantity="concentration",each unit="mg/L");

Real P[17] (each quantity = "pressure", each unit = "Pa") "Potential variable";


end Inlet;

connector Outlet


flow Real Q[17] (each quantity="volumetric flowrate", each unit="L/h") "Flowrate";
output Real c[17] (each quantity="concentration",each unit="mg/L");

Real P[17] (each quantity = "pressure", each unit = "Pa") "Potential variable";


end Outlet;

record membrane_properties

parameter Real n = 7 "Number of capillaries per fiber";
parameter Real m = 15 "Number of Membrane Fibers";
parameter Modelica.SIunits.Length d_cap = 0.0009 "Capillary diameter";
parameter Modelica.SIunits.Length l_m = 1.5 "Capillary membrane length";

end membrane_properties;

record set_flow_parameters

parameter Modelica.SIunits.Velocity u_cf[17] ={0.25, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5, 6, 6.5, 7, 7.5, 8}; Crossflow velocity at the membrane inlet

parameter Real J_p_overall = 35;
in m3/sm2 Average permeate flux as the permeate leaves the membrane 35 L/hm2
parameter Real Y = 0.45;
Water conversion factor (Q_p/Q_raw)
parameter Real k_w = 10.67;
water permeability through the membrane in L/hm
2
parameter Real P_feed = 2.75; used to calculate potential presure terms

end set_flow_parameters;

record Conc_pol_parameters

output

Real Re[17]; Reynoldsnumber
Real Sc[17];
Schmidtnumber
Real Sh[17]; Sherwoodnumber
Real CP[17];
concentration polarization
Real delta[17]; d_h/Sh
Real k[17];
D_i.Sh/d_h";

input
constant Real D_i = 1.07 * 10 (-9) "Diffusion coefficient / m²/s";

end Conc_pol_parameters;

record osmopressure_solute

constant Real R_gasconstant = Modelica.Constants.R;
parameter Real alpha = 1 "disscociation constant

between 0 and 1";

parameter Real T = 293 "temperature /K";
why error
parameter Real v = 2 "stoichiometric coefficient";
c_f is the only variation from one membrane module to the next

Real P_osmotic[17];
Real B;
end osmopressure_solute;

class calculated_flows

constant Real pi = 3.141592;
Real d_h "hydraulic diameter";
extends membrane_properties;
extends set_flow_parameters;
output Real A_cf "Crosssectional flow area / m²";
output Real A_act "Active Membrane area / m²";

equation

d_h = d_cap * m * n;
A_cf = pi * (d_cap / 2) 2 * n * m;
A_act = pi * d_h * l_m;

end calculated_flows;

model Raw_water

Inlet In_MO;
Outlet Out_F;
extends calculated_flows;
Permeate Perm;
parameter Real c_raw_init = 248 "Concentration of contaminant / mg/L";
Real Q_raw_f[17] "raw water flowrate set / L/h ";
Real c_raw[17];
Real Q_p;
Real V[17]"Volume of water in the raw water tank varying with progression of the filtration process with time";
Real V_initial = 500 * 10 3 "Volume of water present in the tank";



initial equation


for i in 1:17 loop


c_raw[i] = c_raw_init;
V[i] = V_initial;
Q_raw_f[i] = J_p_overall * A_act / Y;


end for;


equation
for i in 1:17 loop


initial equation
c_raw[i] = c_raw_init;
V[i] = V_initial;


equation

Out_F.c[i] = c_raw[i];
Out_F.Q[i] = - Q_raw_f[i];
der(V[i]) = - Q_raw_f[i];
der(c_raw[i] * V[i]) = Out_F.Q[i] * Out_F.c[i];

der(V) = In_MO.Q + Out_F.Q ;
der(c_raw * V) = In_MO.Q * In_MO.c ;
In_MO.P = 1;

Out_F.P[i] = 1;


end for;


end Raw_water;

model Feed

Inlet In_raw, In_cyc;
Outlet Out;
extends calculated_flows;
feed flowrate calculated based on fixed feed velocity
Real P_head;
Real Q_f[17];
Real P_f[17];
just display
Real P_rec[17];
just display
Real P_increase_f[17];
Real P_increase_rec[17];
Real P_feed[17];


equation


for i in 1:17 loop


Q_f[i] = u_cf[i] * A_cf * 3600 * 1000;


In_raw.c[i] * In_raw.Q[i] + In_cyc.c[i] * In_cyc.Q[i] + Out.c[i] * Out.Q[i] = 0;
Out.Q[i] = -abs(Q_f[i]);
In_cyc.Q[i] + Out.Q[i] + In_raw.Q[i] = 0;


In_raw.P[i] = P_f[i];
In_cyc.P[i] = P_rec[i];
P_increase_f[i] = P_feed[i] - P_f[i];
P_increase_rec[i] = P_feed[i] - P_rec[i];
Out.P[i] = P_feed[i];


end for;


end Feed;

model Membrane

Inlet In;
Outlet Out_P, Out_M;


Real sn "segment number";
Real R_obssn[17] "rejection considering CP";
Real c_msn[17] "concentration along the membrane / mg/L";
Real c_fsn[17] "concentration of feed or bulk / mg/L";
Real tsn[17] "thickness of boundary layer / m";
Real TMP[17] "transmembrane pressure /bar";
Real WCF[17] "water conversion factor";
Real k[17] "beta, mass transfer coefficient";


Real P_loss "Pressure loss";
Real P_loss_HP[17] "Pressure loss along the membrane length using Hagen-poiseuille equation";
Real P_loss_sn "Pressure loss in each segment";
Real e_sn[17] "energy used in each segment unit";
Real TMP_test;


Real Q_psn[17] "permeate leaving segment n";
Real J_psn[17] "permeate flux through segment sn";
Real u_cfsn[17];
Parameter assumption to test the model-
Pressure varies with velocity and a relationship must be attained experimentally, or J_p(TMP) must be calculated by another method and not Darcy's law
Intrinsic retetntion can be obtained from experimental calculations
Real P_in[17];
Real P_out[17];
Real f_D[17];
parameter Real R_int = 0.9;
intrinsic retention of membrane


parameter Real rho = 998.2 "density of water kg/m3";
parameter Real mu = 1 * 10
(-3) "dynamic viscosity / Pa.s";


extends calculated_flows;
extends Conc_pol_parameters;
extends osmopressure_solute;


equation


for i in 1:17 loop


f_D[i] = 64 / Re[i] "friction factor";


abs(In.c[i]) = c_fsn[i];

Out_P.c = In.c * (1-R); permeate from the membrane calculated based on assumed R value

u_cfsn[i] = In.Q[i] / (A_cf * 3600 * 1000);


P_in[i] = In.P[i];
Out_P.P[i] = 0;

P_loss_sn = f_D * rho * l_m/4 * u_cfsn 2 / (2 * d_cap) * 10(-5);
P_loss = f_D * rho * l_m * sn/4 * u_cfsn 2 / (2 * d_cap) * 10(-5);

P_loss_HP[i] = 0.25 *l_m * sn/4 * u_cfsn [i];

P_loss_HP[i] = In.Q[i] * (8 / (m * n)) * mu * l_m * sn / 4 * 10 (-5) / ((d_cap / 2) 4 * pi * 3.6 * 10 6);

convert from pa to bar - Q from l/h to m3/s, flow is considered to be equally distributed through the m capillaries in the n fibres

P_out[i] = P_in[i] - P_loss_HP[i];
TMP[i] = (P_in[i] + P_out[i]) / 2 - Out_P.P[i];
Out_M.P[i] = P_out[i];

TMP_test = (In.P + Out_M.P)/2;

Q_psn[i] = k_w * TMP[i] * (A_act / 4);
J_psn[i] = Q_psn[i] / (A_act / 4);
Out_P.Q[i] = -abs(Q_psn[i]);
In.Q[i] + Out_P.Q[i] + Out_M.Q[i] = 0;
WCF[i] = abs(Out_P.Q[i] / In.Q[i]);
(CP[i], Re[i], Sc[i], Sh[i], delta[i], k[i]) = Concentration_polarization(d_cap, D_i, l_m * sn / 4, c_fsn[i], u_cfsn[i], J_psn[i], R_int);
(B, P_osmotic[i]) = osmotic_pressure(R_gasconstant, alpha, T, c_msn[i], v);


c_msn[i] = CP[i] * c_fsn[i];
Out_P.c = (1 - R_int) * c_fsn;
R_obssn = 1 - Out_P.c / c_msn;
Out_P.c[i]=(1-R_int)*c_msn[i];
R_obssn[i]=1-(Out_P.c[i]/c_fsn[i]);
tsn[i] = D_i / k[i];
Out_P.c[i] * Out_P.Q[i] + Out_M.c[i] * Out_M.Q[i] + In.c[i] * In.Q[i] = 0;
e_sn[i] = P_loss_HP[i] * u_cfsn[i] * A_cf * 3600 * 1000;


end for;


end Membrane;

model Permeate

Inlet In_P1, In_P2, In_P3, In_P4;
output Real Q_p[17];
output Real c_permeate[17];
extends calculated_flows;


equation


for i in 1:17 loop


Q_p[i] = In_P1.Q[i] + In_P2.Q[i] + In_P3.Q[i] + In_P4.Q[i];
c_permeate[i] = (In_P1.c[i] * In_P1.Q[i] + In_P2.c[i] * In_P2.Q[i] + In_P3.c[i] * In_P3.Q[i] + In_P4.c[i] * In_P4.Q[i]) / Q_p[i];


end for;


end Permeate;

model Membrane_outlet

Inlet In;
Outlet Out_cyc, Out_Ret;
Out_RW
parameter Real rec = -1 "recirculation";


equation
for i in 1:17 loop


Out_Ret.c[i] = In.c[i];
Out_cyc.c[i] = In.c[i];

Out_cyc.Q = -abs(rec);

Out_cyc.Q[i] + Out_Ret.Q[i] + In.Q[i] = 0;
Out_cyc.P[i] = 1;
Out_Ret.P[i] = 1;


end for;


end Membrane_outlet;

model Retentate


Inlet In_Ret;
output Real Q_ret[17];
output Real c_ret[17];
extends calculated_flows;

equation


for i in 1:17 loop

Q_ret[i] = In_Ret.Q[i];
c_ret[i] = In_Ret.c[i];

In_P1.P + In_P2.P + In_P3.P + In_P4.P = 0;

end for;

end Retentate;

class Run


Real WCF_overall[17];
Real Y_overall[17];
Real R_overall[17];
Real P_loss_overall[17];
Real R_raw_overall[17];
Real TMP_overall[17];


extends calculated_flows;


Raw_water RW;
Feed F;
Membrane M1(sn = 1);
Membrane M2(sn = 2);
Membrane M3(sn = 3);
Membrane M4(sn = 4);
Permeate Pn;
Membrane_outlet MO;
Retentate Ret;


equation

connect(RW.Out_F, F.In_raw);
connect(F.Out, M1.In);
connect(M1.Out_P, Pn.In_P1);
connect(M2.Out_P, Pn.In_P2);
connect(M3.Out_P, Pn.In_P3);
connect(M4.Out_P, Pn.In_P4);

final permeate stream is made up of the 4 permeate streams

connect(M1.Out_M, M2.In);
connect(M2.Out_M, M3.In);
connect(M3.Out_M, M4.In);
connect(M4.Out_M, MO.In);
connect(MO.Out_Ret, Ret.In_Ret);
connect(MO.Out_cyc, F.In_cyc);


for i in 1:17 loop


WCF_overall[i] = abs(Pn.Q_p[i] / F.Out.Q[i]);
Y_overall[i] = Pn.Q_p[i] / RW.Q_raw_f[i];
R_overall[i] = 1 - Pn.c_permeate[i] / F.Out.c[i];
R_raw_overall[i] = 1 - Pn.c_permeate[i] / RW.c_raw_init;
P_loss_overall[i] = M1.P_loss_HP[i] + M2.P_loss_HP[i] + M3.P_loss_HP[i] + M4.P_loss_HP[i];
J_p_overall = (M1.Q_psn[i] + M2.Q_psn[i] + M3.Q_psn[i] + M4.Q_psn[i]) / A_act;
TMP_overall[i] = (M1.P_in[i] + M4.P_out[i]) / 2;


end for;


end Run;

function Concentration_polarization

input Real d_cap, D_i, l_m, c_f, u_cf, J_p, R_int;
output Real CP "Concentration polarization / c_0/c_f", Re "Reynold's number", Sc "Schmidt number", Sh "Sherwood number", delta "thickness of boundary layer laminar flow / m", k "Mass transfer coefficient";

protected

constant Real e = Modelica.Constants.e;
Real mu = 1 * 10 (-3) "dynamic viscosity / Pa.s";
Real rho = 998.2 "density of water kg/m
3";

algorithm

Re := d_cap * u_cf * rho / mu;
Sc := mu / (rho * D_i);
if Re < 2300 then

Sh := 1.62 * (Re * Sc * d_cap / l_m) (1 / 3);

else

Sh := 0.04 * Re (3 / 4) * Sc;

end if;
delta := d_cap / Sh "thickness of boundary layer laminar flow / m";
k := D_i / delta "Mass transfer coefficient";
CP := e (J_p / 1000 / 3600 / k) / (R_int + (1 - R_int) * e (J_p / 1000 / 3600 / k)) "Concentration polarization / c_0/c_f";

end Concentration_polarization;

function osmotic_pressure

input Real R_gasconstant, alpha, T, c_f, v;
c_f is the only varaiation from one membrane module to the next
output Real B, P_osmotic;

algorithm

B := 1 + alpha * (v - 1);
P_osmotic := B * R_gasconstant * 10 (-2) * T * c_f / (1000 * 120.3676);

Use magnesium sulphate in moles

end osmotic_pressure;

end SplitM_1;

Change History (5)

comment:1 by Shravya Hebbur Murali <shravya2535@…>, 4 years ago

Owner: changed from Adeel Asghar to Shravya Hebbur Murali <shravya2535@…>
Status: newaccepted

delete

comment:2 by Francesco Casella, 4 years ago

@shravya2535, if you have non-trivial code, please also attach it as a file to the ticket.

We report some information in some cases, but we could of course do much better. I opened #6386 with some suggestions. Feel free to comment on that.

comment:3 by Francesco Casella, 4 years ago

Cc: Andreas Heuermann Philip Hannebohm added
Milestone: NeedsInput1.18.0
Owner: changed from Shravya Hebbur Murali <shravya2535@…> to Karim Adbdelhak
Status: acceptedassigned

comment:4 by Shravya Hebbur Murali <shravya2535@…>, 4 years ago

Owner: changed from Karim Adbdelhak to Shravya Hebbur Murali <shravya2535@…>

comment:5 by Francesco Casella, 3 years ago

Milestone: 1.18.0

Ticket retargeted after milestone closed

Note: See TracTickets for help on using tickets.