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

Some help for defining system of equations

Some help for defining system of equations

Hi,

I want to calculate T in following model. I have made three models. In fist model (dewpoint) I am getting "Jacobian determinant is NaN" and "Invalid root: (1.#INF)^(2)" errors. I tried to simplify  and created second model (dewpoint1) . It is working and giving right results for two components. I tried same equations for three components in third model (dewpoint2) but it is showing error.

Why error coming in dewpoint2?

Is there any reference to learn about solvable systems in openmodelica and how to make other systems solvable?

Thank you in advance

package post
  package Database
    model General
      parameter Real VP[6];
    end General;

    model Methanol
      extends General(VP = {101, 73.40342, -6548.076, -7.409987, 5.72492E-06, 2});
    end Methanol;

    model Ethanol
      extends General(VP = {101, 88.0754, -7652.06, -9.471507, 5.928087E-06, 2});
    end Ethanol;

    model Water
      extends General(VP = {101, 74.55502, -7295.586, -7.442448, 0.0000042881, 2});
    end Water;
  end Database;

  model dewpoint
    parameter Database.General comp[3] = {meth, eth, wat};
    Database data;
    parameter data.Methanol meth;
    parameter data.Ethanol eth;
    parameter data.Water wat;
    Real P = 101325, T(start = 0.001);
    parameter Real z[3] = {0.33, 0.33, 0.34};
   
    equation
     
      1 / P = sum(z ./ exp(comp[:].VP[2] + comp[:].VP[3] / T + comp[:].VP[4] * log(T) + comp[:].VP[5] .* T .^comp[:].VP[6]));
  end dewpoint;

  model dewpoint1
    parameter Database.General comp[NOC] = {meth, eth};
    Database data;
    parameter data.Methanol meth;
    parameter data.Ethanol eth;
    parameter data.Water wat;
    parameter Integer NOC = 2;
    Real P = 101325, T(start = 0.001), Psat[2](each start = 0.001), s[NOC];
    parameter Real z[NOC] = {0.5, 0.5};
   
    equation
      Psat = exp(comp[:].VP[2] + comp[:].VP[3] / T + comp[:].VP[4] * log(T) + comp[:].VP[5] .* T .^comp[:].VP[6]);
      P = product(Psat[:]) / sum(s[:]);
     
    algorithm
     
      for i in 1:NOC loop
        s[i] := 1;
        for j in 1:NOC loop
          if i == j then
            s[i] := s[i] * z[i];
          else
            s[i] := s[i] * Psat[i];
          end if;
        end for;
      end for;
   
  end dewpoint1;

  model dewpoint2
    parameter Database.General comp[3] = {meth, eth, wat};
    Database data;
    parameter data.Methanol meth;
    parameter data.Ethanol eth;
    parameter data.Water wat;
    parameter Integer NOC = 3;
    Real P = 101325, T(start = 0.001, min = 0.001), Psat[3](each start = 0.001), s[NOC];
    parameter Real z[NOC] = {0.33, 0.33, 0.34};
  equation
    Psat = exp(comp[:].VP[2] + comp[:].VP[3] / T + comp[:].VP[4] * log(T) + comp[:].VP[5] .* T .^ comp[:].VP[6]);
    P = product(Psat[:]) / sum(s[:]);
  algorithm
    for i in 1:NOC loop
      s[i] := 1;
      for j in 1:NOC loop
        if i == j then
          s[i] := s[i] * z[i];
        else
          s[i] := s[i] * Psat[i];
        end if;
      end for;
    end for;
  end dewpoint2;
end post;

There are 0 guests and 0 other users also viewing this topic
You are here: