Ignore:
Timestamp:
Mar 7, 2007, 3:09:13 PM (16 years ago)
Author:
Rafael de Pelegrini Soares
Message:

Adapted PID models for the new language (the usage of switcher is still pending)

Location:
branches/newlanguage/sample/controllers
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/newlanguage/sample/controllers/CSTR_noniso_pid.mso

    r84 r190  
    2222using "controllers/PIDs";
    2323
    24 const_valv as positive(Brief = "Valve Constant", Default=1,Lower=0,Upper=100, Unit="m^2.5/h");
     24const_valv as positive(Brief = "Valve Constant", Default=1,Lower=0,Upper=100, Unit='m^2.5/h');
    2525
    2626Model corrente
     
    3434
    3535        PARAMETERS
    36         ko  as frequency                (Unit="1/h");
     36        ko  as frequency                (DisplayUnit='1/h');
    3737        A   as area;
    3838        At  as area;   
    39         Ea  as energy_mol               (Unit="kJ/kmol");
    40         R   as Real                     (Unit="kJ/mol/K");
    41         ro  as dens_mol                 (Unit="kmol/m^3");
    42         Cp  as cp_mol                   (Unit="kJ/kmol/K");
    43         U   as heat_trans_coeff (Unit="kW/m^2/K");
    44         Hr  as heat_reaction    (Unit="kJ/kmol");
     39        Ea  as energy_mol               (DisplayUnit='kJ/kmol');
     40        R   as Real                     (Unit='kJ/mol/K');
     41        ro  as dens_mol                 (DisplayUnit='kmol/m^3');
     42        Cp  as cp_mol                   (DisplayUnit='kJ/kmol/K');
     43        U   as heat_trans_coeff (DisplayUnit='kW/m^2/K');
     44        Hr  as heat_reaction    (DisplayUnit='kJ/kmol');
    4545       
    4646        VARIABLES
     
    5353        tau      as time_h;
    5454        rA           as reaction_mol;
    55         k        as frequency   (Unit="1/h");
     55        k        as frequency   (DisplayUnit='1/h');
    5656in  Inlet    as corrente;
    5757out Outlet   as corrente;
     
    9494        DEVICES
    9595        FEED as corrente;
    96         CSTR as CSTR;
     96        CSTR1 as CSTR;
    9797        PIDL as PID_Ideal_AWBT;
    9898        PIDT as PID_Ideal_AWBT;
     
    107107       
    108108        CONNECTIONS
    109         FEED to CSTR.Inlet;
     109        FEED to CSTR1.Inlet;
    110110       
    111111        SET
    112112#       Parâmetros do CSTR"
    113         CSTR.R   = 8.3144 * "kJ/kmol/K";
    114         CSTR.U   = 300 * "kJ/h/m^2/K";
    115         CSTR.ro  = 55.56 * "kmol/m^3";
    116         CSTR.Cp  = 70*"kJ/kmol/K";
    117         CSTR.Hr  = -7000 * "kJ/kmol";
    118         CSTR.Ea  = 6e4 * "kJ/kmol";
    119         CSTR.ko  = 89 * "1/s";
    120         CSTR.A   = 8 * "m^2";
    121         CSTR.At  = 25 * "m^2";
     113        CSTR1.R   = 8.3144 * 'kJ/kmol/K';
     114        CSTR1.U   = 300 * 'kJ/h/m^2/K';
     115        CSTR1.ro  = 55.56 * 'kmol/m^3';
     116        CSTR1.Cp  = 70*'kJ/kmol/K';
     117        CSTR1.Hr  = -7000 * 'kJ/kmol';
     118        CSTR1.Ea  = 6e4 * 'kJ/kmol';
     119        CSTR1.ko  = 89 * '1/s';
     120        CSTR1.A   = 8 * 'm^2';
     121        CSTR1.At  = 25 * 'm^2';
    122122       
    123123        EQUATIONS
    124124
    125125        "Equações do PID para controle de nível"
    126         L_ad*(Lmax-Lmin)=CSTR.h-Lmin;
     126        L_ad*(Lmax-Lmin)=CSTR1.h-Lmin;
    127127        PIDL.Ports.input=L_ad;
    128128
    129129        "Equações do PID para controle de temperatura"
    130         T_ad*(Tmax-Tmin)=CSTR.T-Tmin;
     130        T_ad*(Tmax-Tmin)=CSTR1.T-Tmin;
    131131        PIDT.Ports.input=T_ad;
    132132       
    133133        "Variáveis manipulada"
    134         CSTR.Cv  = 2.2136 * "m^2.5/h" * (1 - PIDL.Ports.output);
    135         CSTR.Tw  = PIDT.Ports.output*(Tmax-Tmin)+Tmin;
     134        CSTR1.Cv  = 2.2136 * 'm^2.5/h' * (1 - PIDL.Ports.output);
     135        CSTR1.Tw  = PIDT.Ports.output*(Tmax-Tmin)+Tmin;
    136136       
    137137        #distúrbio regulatório
    138138        if time<1.6e5 then     
    139                 FEED.T = 300 * "K";
     139                FEED.T = 300 * 'K';
    140140        else
    141                 FEED.T = 285 * "K";
     141                FEED.T = 285 * 'K';
    142142        end
    143143
     
    152152        PIDL.Options.autoMan=0;
    153153        PIDL.Parameters.gain=20;
    154         PIDL.Parameters.intTime=5*"h";
    155         PIDL.Parameters.derivTime=0*"s";
     154        PIDL.Parameters.intTime=5*'h';
     155        PIDL.Parameters.derivTime=0*'s';
    156156        PIDL.Ports.setPoint=0.55;
    157         PIDL.Parameters.tau=1*"s";
    158         PIDL.Parameters.tauSet=1*"s";
     157        PIDL.Parameters.tau=1*'s';
     158        PIDL.Parameters.tauSet=1*'s';
    159159       
    160160        PIDT.Parameters.bias = 0;
     
    166166        PIDT.Options.autoMan=0;
    167167        PIDT.Parameters.gain=40;
    168         PIDT.Parameters.intTime=5*"h";
    169         PIDT.Parameters.derivTime=1*"h";
     168        PIDT.Parameters.intTime=5*'h';
     169        PIDT.Parameters.derivTime=1*'h';
    170170        PIDT.Ports.setPoint=0.85;
    171         PIDT.Parameters.tau=1*"s";
    172         PIDT.Parameters.tauSet=1*"s";   
     171        PIDT.Parameters.tau=1*'s';
     172        PIDT.Parameters.tauSet=1*'s';   
    173173       
    174174        "Valores limites para normalizações"
    175         Lmax=5*"m";
    176         Lmin=0*"m";
    177         Tmax=700*"K";
    178         Tmin=230*"K";   
     175        Lmax=5*'m';
     176        Lmin=0*'m';
     177        Tmax=700*'K';
     178        Tmin=230*'K';   
    179179       
    180180        "Variáveís da corrente de alimentação"
    181         FEED.Ca = 300 * "kmol/m^3";
    182         FEED.F = 3.5 * "m^3/h";
     181        FEED.Ca = 300 * 'kmol/m^3';
     182        FEED.F = 3.5 * 'm^3/h';
    183183
    184184        INITIAL
    185         CSTR.Ca = 50 * "kmol/m^3";
    186         CSTR.h = 2.5 * "m";
    187         CSTR.T = 650 * "K";
     185        CSTR1.Ca = 50 * 'kmol/m^3';
     186        CSTR1.h = 2.5 * 'm';
     187        CSTR1.T = 650 * 'K';
    188188       
    189189        OPTIONS
    190         time = [0:0.1:1 1:1:100] * "h";
     190        TimeStep = 0.1;
     191        TimeEnd = 100;
     192        TimeUnit = 'h';
    191193end
  • branches/newlanguage/sample/controllers/Sample_flash_pid.mso

    r84 r190  
    3030       
    3131        PARAMETERS
    32         PP      as CalcObject(Brief="Physical Properties",File="vrpp");
     32        PP      as Plugin(Brief="Physical Properties",File="vrpp");
    3333        NComp   as Integer;
    3434        #Valores utilizados na normalização do nível e da pressão do flash
     
    5757        pidP as PIDIncr_Parallel_AWBT;
    5858        fl as flash;
    59         s1 as streamTP;
     59        s1 as source;
    6060       
    6161        SET
     
    6666       
    6767        #Parâmetros do modelo de flash
    68         fl.V = 1 * "m^3";
    69         fl.Across = 0.5* "m^2";
     68        fl.V = 1 * 'm^3';
     69        fl.Across = 0.5* 'm^2';
    7070       
    7171        #Valores máximos e mínimos para as normalizações
    72         PMax=2.36 *"atm";
    73         PMin=0 *"atm";
    74         LMax=2 *"m";
    75         LMin=0 *"m";
    76         FVMax=300*"kmol/h";
    77         FVMin=0*"kmol/h";
    78         FLMax=692.7*"kmol/h";
    79         FLMin=0*"kmol/h";
     72        PMax=2.36 *'atm';
     73        PMin=0 *'atm';
     74        LMax=2 *'m';
     75        LMin=0 *'m';
     76        FVMax=300*'kmol/h';
     77        FVMin=0*'kmol/h';
     78        FLMax=692.7*'kmol/h';
     79        FLMin=0*'kmol/h';
    8080
    8181        CONNECTIONS
    82         s1 to fl.Inlet;
     82        s1.Outlet to fl.Inlet;
    8383        Q to fl.Q;
    8484       
    8585        SPECIFY
    8686
    87         Q = 1026.32 * "kJ/s";
     87        Q = 1026.32 * 'kJ/s';
    8888
    8989        #Parâmetros do controlador de nível
    9090        pidL.Parameters.bias=0.5;
    9191        pidL.Parameters.gain=1.1776;
    92         pidL.Parameters.derivTime=19*"s";
    93         pidL.Parameters.intTime=76*"s";
    94         pidL.Parameters.tau=1*"s";
    95         pidL.Parameters.tauSet=1*"s";
     92        pidL.Parameters.derivTime=19*'s';
     93        pidL.Parameters.intTime=76*'s';
     94        pidL.Parameters.tau=1*'s';
     95        pidL.Parameters.tauSet=1*'s';
    9696        pidL.Parameters.alpha =1;
    9797        pidL.Parameters.beta =1;
     
    106106        pidP.Parameters.bias=0.5;       
    107107        pidP.Parameters.gain=0.9275;
    108         pidP.Parameters.derivTime=18*"s";
    109         pidP.Parameters.intTime=72*"s";
    110         pidP.Parameters.tau=1*"s";
    111         pidP.Parameters.tauSet=1*"s";
     108        pidP.Parameters.derivTime=18*'s';
     109        pidP.Parameters.intTime=72*'s';
     110        pidP.Parameters.tau=1*'s';
     111        pidP.Parameters.tauSet=1*'s';
    112112        pidP.Parameters.alpha =1;
    113113        pidP.Parameters.beta =1;
     
    120120        EQUATIONS
    121121        #Corrente de entrada do flash
    122         s1.z = [0.3, 0.3, 0.4];
    123         s1.P = 5 * "atm";       
     122        s1.Outlet.z = [0.3, 0.3, 0.4]; 
     123        s1.Outlet.P = 5 * 'atm';       
    124124       
    125125        #Distúrbio regulatório
    126126        if time<2000 then
    127                 s1.T = 338 * "K";
    128                 s1.F = 496.3 * "kmol/h";
     127                s1.Outlet.T = 338 * 'K';
     128                s1.Outlet.F = 496.3 * 'kmol/h';
    129129        else
    130                 s1.T = 360 * "K";
    131                 s1.F = 450 * "kmol/h";
     130                s1.Outlet.T = 360 * 'K';
     131                s1.Outlet.F = 450 * 'kmol/h';
    132132        end
    133133
     
    154154
    155155        INITIAL
    156         fl.OutletL.T = 340 *"K";
    157         fl.Level = 1* "m";
     156        fl.OutletL.T = 340 *'K';
     157        fl.Level = 1* 'm';
    158158        fl.OutletL.z(1) = 0.1;
    159159        fl.OutletL.z(2) = 0.1;
    160160
    161161        OPTIONS
    162         relativeAccuracy = 1e-6;
     162        RelativeAccuracy = 1e-6;
    163163        #time = [0:100:7000 7000:0.10:8150 8150:100:10000];
    164         time = [0:100:10000];
     164        TimeStep = 100;
     165        TimeEnd = 10000;
    165166end
    166167
  • branches/newlanguage/sample/controllers/sample_tanks_pid.mso

    r84 r190  
    3333       
    3434        PARAMETERS     
    35         h_max as Real (Brief="Altura máxima do nível do tanque", Unit="m");
    36         h_min as Real (Brief="Altura mínima do nível do tanque", Unit="m");
     35        h_max as Real (Brief="Altura máxima do nível do tanque", Unit='m');
     36        h_min as Real (Brief="Altura mínima do nível do tanque", Unit='m');
    3737
    3838    VARIABLES
     
    4242       
    4343        SET
    44         Tanque1.A = 8 * "m^2";
    45         h_max = 2 * "m";
    46         h_min = 0 * "m";
     44        Tanque1.A = 8 * 'm^2';
     45        h_max = 2 * 'm';
     46        h_min = 0 * 'm';
    4747
    4848        EQUATIONS
    49         PID.Parameters.tau = 1*"s";     
    50         PID.Parameters.tauSet = 1*"s"
     49        PID.Parameters.tau = 1*'s';     
     50        PID.Parameters.tauSet = 1*'s'
    5151        PID.Parameters.alpha = 0.3;
    5252        PID.Parameters.bias = 0;       
     
    5656        PID.Options.clip=1;
    5757        PID.Options.autoMan = 0;
    58         PID.Parameters.intTime=5000*"s";
     58        PID.Parameters.intTime=5000*'s';
    5959        PID.Parameters.gain = 3.5;
    60         PID.Parameters.derivTime=1*"s";
     60        PID.Parameters.derivTime=1*'s';
    6161        PID.Ports.input = h_ad;
    6262        h_ad = (Tanque1.h-h_min)/(h_max-h_min);
    63         Tanque1.k = 8*"m^2.5/h"*PID.Ports.output;       
     63        Tanque1.k = 8*'m^2.5/h'*PID.Ports.output;       
    6464
    6565        #Perturbação servo
    66         #Nível desejado=1*"m"
     66        #Nível desejado=1*'m'
    6767        PID.Ports.setPoint=0.5;
    6868
    6969        #Perturbação regulatória
    7070        if time<10*"h" then
    71                 Tanque1.Fin= 3*"m^3/h";
     71                Tanque1.Fin= 3*'m^3/h';
    7272        else
    73                 Tanque1.Fin= 1.5*"m^3/h";
     73                Tanque1.Fin= 1.5*'m^3/h';
    7474        end     
    7575       
    7676        INITIAL
    7777        "altura inicial"
    78         Tanque1.h = 0.2 * "m";
     78        Tanque1.h = 0.2 * 'm';
    7979       
    8080        OPTIONS
    8181        DAESolver = "dassl";
    82         time = [0:0.1:30] * "h" ;
     82        TimeStep = 0.1;
     83        TimeEnd = 30;
     84        TimeUnit = 'h';
    8385end
    8486
     
    8991       
    9092        PARAMETERS     
    91         h_max as Real (Brief="Altura máxima do nível do tanque", Unit="m");
    92         h_min as Real (Brief="Altura mínima do nível do tanque", Unit="m");
     93        h_max as Real (Brief="Altura máxima do nível do tanque", Unit='m');
     94        h_min as Real (Brief="Altura mínima do nível do tanque", Unit='m');
    9395
    9496    VARIABLES
     
    98100       
    99101        SET
    100         Tanque1.A = 8 * "m^2";
    101         h_max = 2 * "m";
    102         h_min = 0 * "m";
     102        Tanque1.A = 8 * 'm^2';
     103        h_max = 2 * 'm';
     104        h_min = 0 * 'm';
    103105
    104106        EQUATIONS
    105         PID.Parameters.tau = 1*"s";     
    106     PID.Parameters.tauSet = 1*"s";     
     107        PID.Parameters.tau = 1*'s';     
     108    PID.Parameters.tauSet = 1*'s';     
    107109        PID.Parameters.alpha = 0.3;
    108110        PID.Parameters.bias = 0;
    109111        PID.Parameters.gamma = 1;
    110112        PID.Parameters.beta = 1;
    111         PID.Parameters.intTime=5000*"s";
     113        PID.Parameters.intTime=5000*'s';
    112114        PID.Parameters.gain =3.5;
    113         PID.Parameters.derivTime=1*"s";
     115        PID.Parameters.derivTime=1*'s';
    114116        PID.Options.action = -1;
    115117        PID.Options.clip=1;
     
    117119        PID.Ports.input = h_ad;
    118120        h_ad = (Tanque1.h-h_min)/(h_max-h_min);
    119         Tanque1.k = 8*"m^2.5/h"*PID.Ports.output;       
     121        Tanque1.k = 8*'m^2.5/h'*PID.Ports.output;       
    120122
    121123        #Perturbação servo
    122         #Nível desejado=1*"m"
     124        #Nível desejado=1*'m'
    123125        PID.Ports.setPoint=0.5;
    124126
    125127        #Perturbação regulatória
    126128        if time<10*"h" then
    127                 Tanque1.Fin= 3*"m^3/h";
     129                Tanque1.Fin= 3*'m^3/h';
    128130        else
    129                 Tanque1.Fin= 1.5*"m^3/h";
     131                Tanque1.Fin= 1.5*'m^3/h';
    130132        end
    131133       
    132134        INITIAL
    133135        "altura inicial"
    134         Tanque1.h = 0.2 * "m";
     136        Tanque1.h = 0.2 * 'm';
    135137       
    136138        OPTIONS
    137139        NLASolver = "sundials";
    138         time = [0:0.1:30] * "h" ;
     140        TimeStep = 0.1;
     141        TimeEnd = 30;
     142        TimeUnit = 'h';
    139143end
    140144
  • branches/newlanguage/sample/controllers/tanksmodel.mso

    r84 r190  
    2525
    2626        VARIABLES
    27         k    as Real (Brief="Valve Constant", Unit = "m^2.5/h", Default=4);
     27        k    as Real (Brief="Valve Constant", Unit = 'm^2.5/h', Default=4);
    2828    h    as length(Brief="Tank level");
    2929        Fin  as flow_vol(Brief="Input flow");
Note: See TracChangeset for help on using the changeset viewer.