[Scilab-users] Modify coselica block in xcos

Michal Lanczont m.lanczont at pollub.pl
Fri Mar 7 13:15:54 CET 2014


I need to edit and modify *MTH_HeatCapacitor* block. I was trying to add
*RealInput*, and edit equation and get heat Capacity dependet from input
real variable. I get coselica sorce, and edit file coselica.mo :
      /model HeatCapacitor_2 "Lumped thermal element storing heat"
        parameter Real C "Heat capacity of part (= cp*m)";
        parameter Real steadyStateStart = 0 "true, if component shall start
in steady state";
        parameter Real T_start = 293.15 "Initial temperature of part (in
Kelvin)";
        Real T(final start = T_start, final fixed = true) "Temperature of
part";
        Modelica.Blocks.Interfaces.RealInput Gc;
        Interfaces.HeatPort_b port;
      equation
        T = port.T;
        C * der(T) = port.Q_flow * Gc.signal;
      initial equation
        if steadyStateStart > 0.0 then
          der(T) = 0;
        else
          T = port.T;
        end if;
      end HeatCapacitor_2;/

and MTH_HeatCapacitor_2.sci:

/function [x,y,typ]=MTH_HeatCapacitor_2(job,arg1,arg2)
    x=[];y=[];typ=[];
    select job
     case 'set' then
      x=arg1;
      graphics=arg1.graphics;exprs=graphics.exprs;
      model=arg1.model;
      while %t do
          [ok,C,steadyStateStart,T_start,exprs]=...
              getvalue(['MTH_HeatCapacitor_2';__('Lumped thermal element
storing heat')],...
                       [__('C [J/K] : Heat capacity of part (= cp*m)');...
                        __('steadyStateStart [-] : true, if component shall
start in steady state');...
                        __('T_start [K] : Initial temperature of part (in
Kelvin)')],...
                       list('vec',1,'vec',1,'vec',1),exprs);
          if ~ok then break, end
          model.rpar=[C,steadyStateStart,T_start];
          model.equations.parameters(2)=list(C,steadyStateStart,T_start)
          graphics.exprs=exprs;
          x.graphics=graphics;x.model=model;
          break
      end
     case 'define' then
      model=scicos_model();
      C=1;
      steadyStateStart=0;
      T_start=293.15;
      model.rpar=[C;steadyStateStart;T_start];
      model.sim='MTH_HeatCapacitor_2';
      model.blocktype='c';
      model.dep_ut=[%t %f];
      mo=modelica();
      mo.model='MTH_HeatCapacitor_2';
      mo.inputs=['Gc'];
      mo.outputs=['port'];
      mo.parameters=list(['C','steadyStateStart','T_start'],...
                         list(C,steadyStateStart,T_start),...
                         [0,0,0]);
      model.equations=mo;
      model.in=ones(size(mo.inputs,'*'),1);
      model.out=ones(size(mo.outputs,'*'),1);
      exprs=string([C;steadyStateStart;T_start]);
      gr_i=[];
      x=standard_define([2 2],model,exprs,list(gr_i,0));
      x.graphics.in_implicit=['I'];
      x.graphics.in_style=[RealInputStyle()];
      x.graphics.out_implicit=['I'];
      x.graphics.out_style=[ThermalOutputStyle()];
    end
endfunction
/
i also add new blok definition files to list of blocks in some other files.
Everytink was compile fine. But when i try use this new block i get an
error:
/*ERROR 0001:
--- Unknown identifier "Gc"

--- Execution step: Name resolution

--- Source:*/

And now i have no idea what is wrong? Pleas *HELP*!





--
View this message in context: http://mailinglists.scilab.org/Modify-coselica-block-in-xcos-tp4029131.html
Sent from the Scilab users - Mailing Lists Archives mailing list archive at Nabble.com.



More information about the users mailing list