Solved

Matlab problem with my program : i can't find the temperature .. ?

Posted on 2012-04-05
1
550 Views
Last Modified: 2016-03-02
hello,  i have a problem with my solution in Matlab...
i can't find the good temperature using this condition : V1<=V1crit && erreur1 < 0.03.
(Temperature needs to be between 65 Celsius et 100 Celsius) (pressure = 750 mmhg )
any ideas..?
Thank you
here is my code...


clear all
clc

format short e
syms phi


liq=712.8636+178.216;
vap=31854+174.84+735.28+2736;          

alim=liq+vap;                                             % en mol/s
z=[0.0195889 0.004897227 0.875321506 0.004804458 0.020204884 0.075183011];                  %composition in

%constantes Antoine (in the order Ch3OH et H2O)
A=[7.87863 7.96681 6.84471 6.88555 0 6.49457];
B=[1473.11 1668.210 1060.793 1175.817 0 255.68];
C=[230 228 231.541 224.867 0 266.55];

Psat=zeros(1,6);    %en mmHg
k=zeros(1,6);

P=input('entrer la pression d''operation en mmhg: \n');
Ptot = 760*P;

critere = 10;
while critere ~= 1
   
   
    T=input('entrez une température entre 65 C et 100 C (pour 750 mmHg): \n'); %Temp??
    y=10;
   
    %calcul des ki
       
    for i=1:length(z) %a verifier
        Psat(i) = 10^(A(i) - B(i)/(T+C(i)));
        k(i) = Psat(i)/Ptot; %constantes d'équilibre
    end
   
    %************************
    % Equation Rachford-Rice
    %************************
   
   
    %composition melange eau-methanol
    z1=(z(1)*alim/liq);
    z2=(z(2)*alim/liq);
   
    N=10^5;          %Nombre d'iterations
    phi=0.5;        %valeur initiale
    epsilon=0.02;
   
    for i=1:N
       
        %Méthode de Newton
        fphi=(z1*(1-k(1))/(1+phi*(k(1)-1))) + (z2*(1-k(2))/(1+phi*(k(2)-1)));
        fphiprime=(z1*(k(1)-1)^2)/(1+phi*(k(1)-1))^2 + (z2*(k(2)-1)^2)/(1+phi*(k(2)-1))^2;
       
        phidot = phi - (fphi/fphiprime);
        erreur=abs(phidot-phi)/abs(phidot);
       
        if erreur <= epsilon && phidot > 0 && phidot <= 1
            phi=phidot;
            break
        end
        phi=phidot;
    end
   
    if phi < 0 || phi > 1
        fprintf('\n **phi doesn't converge')
        y=1;
    end
    phi
   
    %******************************************
    %calcul des compositions de sortie liquide
    %******************************************
   
   
    %composition pour la sortie liquide
    x1out = z1/(1+phi*(k(1)-1));
    x2out = z2/(1+phi*(k(2)-1));
   
    %composition pour calculer la vapeur qui sort
    %   x1 = z(1)/(1+phi*(k(1)-1));
    %   x2 = z(2)/(1+phi*(k(2)-1));
   
    %  y1 = k(1)*x1out;
    %  y2 = k(2)*x2out;
   
    V = phi*(liq)+vap;          %en mol/s
    L = alim - V;               %en mol/s
   
   
    %débits gazeux de ch3oh et eau a la conduite de recyclage
   
    %   V1 = phi*liq*y1;
    %   V2 = phi*liq*y2;
   
    L1 = L*x1out;
    L2 = L*x2out;
   
    V1=z(1)*alim-L1;
    V2=z(2)*alim-L2;
   
    y1=V1/V;
    y2=V2/V;
    y3=z(3)*alim/V;
    y4=z(4)*alim/V;
    y5=z(5)*alim/V;
    y6=z(6)*alim/V;
   
   
    %débits attendus dans la recirculation
    V1crit=38e3*0.0034;
    V2crit=38e3*0.00062;
   
    %*********************************************************************
    % Vérification de la composition (gaz et liquide) et du bilan massique
    %*********************************************************************
    Xestime = x1out+x2out;
    erreur = abs(1-Xestime);
   
    Yestime= y1+y2+y3+y4+y5+y6;
    erreur1=abs(1-Yestime);
   
     if y~=1
        if abs(erreur) < 0.03
            fprintf('**Composition liquide OK \n')
        else
            fprintf('la composition de liquide not ok\n')
            Xestime
        end

        if V1<=V1crit && erreur1 < 0.03
            fprintf('**Composition gaz OK \n')
        else
            fprintf('la composition de gaz not ok \n\n')
            Yestime
        end

        if abs(alim-L-V)<1
            fprintf('**Bilan massique OK \n')
        else
            fprintf('Le bilan not ok \n')
        end

    end
   
   
    critere=input('\n try new parametre (yes=any numbers,no=1)? : \n');
   
end

Xsomme=Xestime
Ysomme=Yestime

x = [x1out x2out]
y = [y1 y2 y3 y4 y5 y6]

L
V

V1
0
Comment
Question by:kriftsi
1 Comment
 
LVL 15

Accepted Solution

by:
yuk99 earned 500 total points
ID: 37814735
I don't understand the question. Please reformulate it clearer. Try to show less code just to reproduce the problem. And please use only English.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
Today companies are subjected to more-and-more data, and it won't stop any time soon.  But there are obvious opportunities for reducing data, particularly data duplicated among companies.
The viewer will learn how to create multiple layers to apply various filters and how to delete areas from each layer’s filter.
This video will demonstrate how to find the puppet warp tool from the edit menu and where to put the points to edit.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now