diff options
author | Sunil Shetye | 2018-06-07 17:48:55 +0530 |
---|---|---|
committer | Sunil Shetye | 2018-06-07 17:48:55 +0530 |
commit | 75a3a91595f06a1ac7d8ccc0a1ca0b5cd9552abf (patch) | |
tree | 2b584d8b6062684bd18beab96c5de019bd9c81c9 /macros/Electrical | |
parent | f97e60278c61e42308c32047109fcb983ded8dcd (diff) | |
download | sci2js-75a3a91595f06a1ac7d8ccc0a1ca0b5cd9552abf.tar.gz sci2js-75a3a91595f06a1ac7d8ccc0a1ca0b5cd9552abf.tar.bz2 sci2js-75a3a91595f06a1ac7d8ccc0a1ca0b5cd9552abf.zip |
add macros from scicos_blocks from scilab 5.5.2
Diffstat (limited to 'macros/Electrical')
24 files changed, 1736 insertions, 0 deletions
diff --git a/macros/Electrical/CCS.sci b/macros/Electrical/CCS.sci new file mode 100644 index 00000000..31d60024 --- /dev/null +++ b/macros/Electrical/CCS.sci @@ -0,0 +1,85 @@ +// Scicos +// +// Copyright (C) INRIA - METALAU Project <scicos@inria.fr> +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// See the file ../license.txt +// + +function [x,y,typ]=CCS(job,arg1,arg2) + // the automatically generated interface block for Modelica CCS.mo model + // - avec un dialogue de saisie de parametre + x=[]; + y=[]; + typ=[]; + select job + case "set" then + x=arg1; + graphics=arg1.graphics; + exprs=graphics.exprs + model=arg1.model; + x=arg1 + case "define" then + ModelName="CCS" + PrametersValue=[] + ParametersName=[] + model=scicos_model() + Typein=[]; + Typeout=[]; + MI=[]; + MO=[] + P=[2,50,1,0; 70,98,2,0;70,2,-2,0] + + PortName=["Iin";"p";"n"] + + for i=1:size(P,"r") + if P(i,3)==1 then + Typein= [Typein; "E"]; + MI=[MI;PortName(i)]; + end + if P(i,3)==2 then + Typein= [Typein; "I"]; + MI=[MI;PortName(i)]; + end + if P(i,3)==-1 then + Typeout=[Typeout;"E"]; + MO=[MO;PortName(i)]; + end + if P(i,3)==-2 then + Typeout=[Typeout;"I"]; + MO=[MO;PortName(i)]; + end + end + model=scicos_model() + mo=modelica() + model.sim=ModelName; + mo.inputs=MI; + mo.outputs=MO; + model.rpar=PrametersValue; + mo.parameters=list(ParametersName,PrametersValue,zeros(ParametersName)); + exprs=[] + gr_i=[] + model.blocktype="c" + model.dep_ut=[%f %t] + mo.model=ModelName + model.equations=mo + model.in=ones(size(MI,"*"),1) + model.out=ones(size(MO,"*"),1) + x=standard_define([2.1,3],model,exprs,list(gr_i,0)) + x.graphics.in_implicit=Typein; + x.graphics.out_implicit=Typeout; + end +endfunction diff --git a/macros/Electrical/CVS.sci b/macros/Electrical/CVS.sci new file mode 100644 index 00000000..a4c7a6bb --- /dev/null +++ b/macros/Electrical/CVS.sci @@ -0,0 +1,84 @@ +// Scicos +// +// Copyright (C) INRIA - METALAU Project <scicos@inria.fr> +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// See the file ../license.txt +// + +function [x,y,typ]=CVS(job,arg1,arg2) + // the automatically generated interface block for Modelica CVS.mo model + // - avec un dialogue de saisie de parametre + x=[]; + y=[]; + typ=[]; + select job + case "set" then + x=arg1; + graphics=arg1.graphics; + exprs=graphics.exprs + model=arg1.model; + x=arg1 + case "define" then + ModelName="CVS" + PrametersValue=[] + ParametersName=[] + model=scicos_model() + Typein=[]; + Typeout=[]; + MI=[]; + MO=[] + P=[2,50,1,0; 70,98,2,0;70,2,-2,0] + + PortName=["vin";"p";"n"] + for i=1:size(P,"r") + if P(i,3)==1 then + Typein= [Typein; "E"]; + MI=[MI;PortName(i)]; + end + if P(i,3)==2 then + Typein= [Typein; "I"]; + MI=[MI;PortName(i)]; + end + if P(i,3)==-1 then + Typeout=[Typeout;"E"]; + MO=[MO;PortName(i)]; + end + if P(i,3)==-2 then + Typeout=[Typeout;"I"]; + MO=[MO;PortName(i)]; + end + end + model=scicos_model() + mo=modelica() + model.sim=ModelName; + mo.inputs=MI; + mo.outputs=MO; + model.rpar=PrametersValue; + mo.parameters=list(ParametersName,PrametersValue,zeros(ParametersName)); + exprs=[] + gr_i=[] + model.blocktype="c" + model.dep_ut=[%f %t] + mo.model=ModelName + model.equations=mo + model.in=ones(size(MI,"*"),1) + model.out=ones(size(MO,"*"),1) + x=standard_define([2.1,3],model,exprs,list(gr_i,0)) + x.graphics.in_implicit=Typein; + x.graphics.out_implicit=Typeout; + end +endfunction diff --git a/macros/Electrical/Capacitor.sci b/macros/Electrical/Capacitor.sci new file mode 100644 index 00000000..3d6a9dc8 --- /dev/null +++ b/macros/Electrical/Capacitor.sci @@ -0,0 +1,71 @@ +// Scicos +// +// Copyright (C) INRIA - METALAU Project <scicos@inria.fr> +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// See the file ../license.txt +// + +function [x,y,typ]=Capacitor(job,arg1,arg2) + // exemple d'un bloc implicit, + // - sans entree ni sortie de conditionnement + // - avec une entree et une sortie de type implicit et de dimension 1 + // - avec un dialogue de saisie de parametre + x=[]; + y=[]; + typ=[]; + select job + case "set" then + x=arg1; + graphics=arg1.graphics; + exprs=graphics.exprs + model=arg1.model; + while %t do + [ok,C,v,exprs]=scicos_getvalue("Set Capacitor block parameter",.. + ["C (F)";"Initial Voltage"],list("vec",1,"vec",1),exprs) + if ~ok then + break, + end + model.rpar=C + model.equations.parameters(2)=list(C,v) + graphics.exprs=exprs + x.graphics=graphics; + x.model=model + break + end + case "define" then + model=scicos_model() + C=0.01,v=0 + model.rpar=[C;v] + model.sim="Capacitor" + model.blocktype="c" + model.dep_ut=[%t %f] + mo=modelica() + mo.model="Capacitor" + mo.inputs="p"; + mo.outputs="n"; + mo.parameters=list(["C","v"],list(C,v),[0,1]) + model.equations=mo + model.in=ones(size(mo.inputs,"*"),1) + model.out=ones(size(mo.outputs,"*"),1) + + exprs=string([C;v]) + gr_i=[]; + x=standard_define([2 1.1],model,exprs,list(gr_i,0)) + x.graphics.in_implicit=["I"] + x.graphics.out_implicit=["I"] + end +endfunction diff --git a/macros/Electrical/ConstantVoltage.sci b/macros/Electrical/ConstantVoltage.sci new file mode 100644 index 00000000..cff44efa --- /dev/null +++ b/macros/Electrical/ConstantVoltage.sci @@ -0,0 +1,69 @@ +// Scicos +// +// Copyright (C) INRIA - METALAU Project <scicos@inria.fr> +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// See the file ../license.txt +// + +function [x,y,typ]=ConstantVoltage(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,V,exprs]=scicos_getvalue("Set ConstantVoltage block parameter",.. + "V (volt)",list("vec",1),exprs) + if ~ok then + break, + end + model.rpar=V + model.equations.parameters(2)=list(V) + graphics.exprs=exprs + x.graphics=graphics; + x.model=model + break + end + + case "define" then + V=0.01 + + model=scicos_model() + model.rpar=V + model.in=1;model.out=1; + model.sim="ConstantVoltage"; + model.blocktype="c" + model.dep_ut=[%f %f] + mo=modelica() + mo.model="ConstantVoltage"; + mo.inputs="p"; + mo.outputs="n"; + mo.parameters=list("V",list(V)) + model.equations=mo + exprs=string(V) + + gr_i=[] + + x=standard_define([1.5 1.1],model,exprs,list(gr_i,0)) + x.graphics.in_implicit=["I"] + x.graphics.out_implicit=["I"] + end +endfunction diff --git a/macros/Electrical/CurrentSensor.sci b/macros/Electrical/CurrentSensor.sci new file mode 100644 index 00000000..84d42296 --- /dev/null +++ b/macros/Electrical/CurrentSensor.sci @@ -0,0 +1,47 @@ +// Scicos +// +// Copyright (C) INRIA - METALAU Project <scicos@inria.fr> +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// See the file ../license.txt +// + +function [x,y,typ]=CurrentSensor(job,arg1,arg2) + x=[]; + y=[]; + typ=[]; + select job + case "set" then + x=arg1; + case "define" then + model=scicos_model() + model.in=1; + model.out=[1; 1]; + model.sim="CurrentSensor" + model.blocktype="c" + model.dep_ut=[%t %f] + mo=modelica() + mo.model="CurrentSensor" + mo.inputs="p"; + mo.outputs=["n";"i"] + model.equations=mo + exprs=[] + gr_i=[] + x=standard_define([2 2],model,exprs,list(gr_i,0)) + x.graphics.in_implicit=["I"] + x.graphics.out_implicit=["I";"E"] + end +endfunction diff --git a/macros/Electrical/Diode.sci b/macros/Electrical/Diode.sci new file mode 100644 index 00000000..0ca08fd9 --- /dev/null +++ b/macros/Electrical/Diode.sci @@ -0,0 +1,74 @@ +// Scicos +// +// Copyright (C) INRIA - METALAU Project <scicos@inria.fr> +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// See the file ../license.txt +// + +function [x,y,typ]=Diode(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,Ids,Vt,Maxexp,R,exprs]=scicos_getvalue("Set Diode block parameter",.. + ["Saturation cuurent (A)";.. + "Voltage equivalent to temperature (Volt)";.. + "Max exponent for linear continuation";.. + "R (ohm)"], list("vec",1,"vec",1,"vec",1,"vec",1),exprs) + if ~ok then + break, + end + model.rpar=[Ids;Vt;Maxexp;R] + model.equations.parameters=list(["Ids","Vt","Maxexp","R"],list(Ids,Vt,Maxexp,R)) + graphics.exprs=exprs + x.graphics=graphics; + x.model=model + break + end + case "define" then + Ids=1.e-6; + Vt=0.04; + Maxexp=15; + R=1.e8; + model=scicos_model() + model.rpar=[Ids;Vt;Maxexp;R] + + model.in=1; + model.out=1; + model.sim="Diode"; + model.blocktype="c" + model.dep_ut=[%t %f] + mo=modelica() + mo.model="Diode"; + mo.inputs="p"; + mo.outputs="n"; + mo.parameters=list(["Ids","Vt","Maxexp","R"],list(Ids,Vt,Maxexp,R)) + + model.equations=mo + exprs=string([Ids;Vt;Maxexp;R]) + gr_i=[] + x=standard_define([2 1],model,exprs,list(gr_i,0)) + x.graphics.in_implicit=["I"] + x.graphics.out_implicit=["I"] + end +endfunction diff --git a/macros/Electrical/Ground.sci b/macros/Electrical/Ground.sci new file mode 100644 index 00000000..73172434 --- /dev/null +++ b/macros/Electrical/Ground.sci @@ -0,0 +1,50 @@ +// Scicos +// +// Copyright (C) INRIA - METALAU Project <scicos@inria.fr> +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// See the file ../license.txt +// + +function [x,y,typ]=Ground(job,arg1,arg2) + // exemple d'un bloc implicit, + // - sans entree ni sortie de conditionnement + // - avec une entree et une sortie de type implicit et de dimension 1 + // - avec un dialogue de saisie de parametre + x=[]; + y=[]; + typ=[]; + select job + case "set" then + x=arg1; + case "define" then + model=scicos_model() + model.in=[1]; + model.out=[]; + model.sim="Ground" + model.blocktype="c" + model.dep_ut=[%t %f] + mo=modelica() + mo.model="Ground" + mo.inputs="p"; + model.equations=mo + exprs="" + gr_i=[] + x=standard_define([1 1],model,exprs,list(gr_i,0)) + x.graphics.in_implicit=["I"] + x.graphics.out_implicit=["I"] + end +endfunction diff --git a/macros/Electrical/Gyrator.sci b/macros/Electrical/Gyrator.sci new file mode 100644 index 00000000..8cec7e60 --- /dev/null +++ b/macros/Electrical/Gyrator.sci @@ -0,0 +1,93 @@ +// Scicos +// +// Copyright (C) INRIA - METALAU Project <scicos@inria.fr> +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// See the file ../license.txt +// + +function [x,y,typ]=Gyrator(job,arg1,arg2) + // the automatically generated interface block for Modelica Gyrator.mo model + // - avec un dialogue de saisie de parametre + x=[]; + y=[]; + typ=[]; + select job + case "set" then + x=arg1; + graphics=arg1.graphics; + exprs=graphics.exprs + model=arg1.model; + x=arg1 + exprs=x.graphics.exprs + while %t do + [ok,G1,G2,exprs]=scicos_getvalue(["Set Gyrator block parameters:";"";"G1: Gyration conductance";"G2: Gyration conductance"],["G1";"G2"],list("vec",1,"vec",1),exprs) + if ~ok then + break, + end + x.model.equations.parameters(2)=list(G1,G2) + x.graphics.exprs=exprs + break + end + case "define" then + ModelName="Gyrator" + PrametersValue=[1;1] + ParametersName=["G1";"G2"] + model=scicos_model() + Typein=[]; + Typeout=[]; + MI=[]; + MO=[] + P=[2.5,90,2,0;2.5,10,2,0;97.5,90,-2,0;97.5,10,-2,0] + PortName=["p1";"n1";"p2";"n2"] + for i=1:size(P,"r") + if P(i,3)==1 then + Typein= [Typein; "E"]; + MI=[MI;PortName(i)]; + end + if P(i,3)==2 then + Typein= [Typein; "I"]; + MI=[MI;PortName(i)]; + end + if P(i,3)==-1 then + Typeout=[Typeout;"E"]; + MO=[MO;PortName(i)]; + end + if P(i,3)==-2 then + Typeout=[Typeout;"I"]; + MO=[MO;PortName(i)]; + end + end + model=scicos_model() + mo=modelica() + model.sim=ModelName; + mo.inputs=MI; + mo.outputs=MO; + model.rpar=PrametersValue; + mo.parameters=list(ParametersName,PrametersValue,zeros(ParametersName)); + exprs=["1";"1"] + gr_i=[] + model.blocktype="c" + model.dep_ut=[%f %t] + mo.model=ModelName + model.equations=mo + model.in=ones(size(MI,"*"),1) + model.out=ones(size(MO,"*"),1) + x=standard_define([2,2],model,exprs,list(gr_i,0)) + x.graphics.in_implicit=Typein; + x.graphics.out_implicit=Typeout; + end +endfunction diff --git a/macros/Electrical/IdealTransformer.sci b/macros/Electrical/IdealTransformer.sci new file mode 100644 index 00000000..2eddd211 --- /dev/null +++ b/macros/Electrical/IdealTransformer.sci @@ -0,0 +1,94 @@ +// Scicos +// +// Copyright (C) INRIA - METALAU Project <scicos@inria.fr> +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// See the file ../license.txt +// + +function [x,y,typ]=IdealTransformer(job,arg1,arg2) + // the automatically generated interface block for Modelica Transformer.mo model + // - avec un dialogue de saisie de parametre + x=[]; + y=[]; + typ=[]; + select job + case "set" then + x=arg1; + graphics=arg1.graphics; + exprs=graphics.exprs + model=arg1.model; + x=arg1 + exprs=x.graphics.exprs + while %t do + [ok,N,exprs]=scicos_getvalue(["Set Transformer block parameters:";"";"N:"+... + " Turn ratio (N1/N2)"],["N"],list("vec",1),exprs) + if ~ok then + break, + end + x.model.equations.parameters(2)=list(N) + x.graphics.exprs=exprs + break + end + case "define" then + ModelName="IdealTransformer" + PrametersValue=[1] + ParametersName=["N"] + model=scicos_model() + Typein=[]; + Typeout=[]; + MI=[]; + MO=[] + P=[2.5,90,2,0;2.5,10,2,0;97.5,90,-2,0;97.5,10,-2,0] + PortName=["p1";"n1";"p2";"n2"] + for i=1:size(P,"r") + if P(i,3)==1 then + Typein= [Typein; "E"]; + MI=[MI;PortName(i)]; + end + if P(i,3)==2 then + Typein= [Typein; "I"]; + MI=[MI;PortName(i)]; + end + if P(i,3)==-1 then + Typeout=[Typeout;"E"]; + MO=[MO;PortName(i)]; + end + if P(i,3)==-2 then + Typeout=[Typeout;"I"]; + MO=[MO;PortName(i)]; + end + end + model=scicos_model() + mo=modelica() + model.sim=ModelName; + mo.inputs=MI; + mo.outputs=MO; + model.rpar=PrametersValue; + mo.parameters=list(ParametersName,PrametersValue,zeros(ParametersName)); + exprs=["1"] + gr_i=[] + model.blocktype="c" + model.dep_ut=[%f %t] + mo.model=ModelName + model.equations=mo + model.in=ones(size(MI,"*"),1) + model.out=ones(size(MO,"*"),1) + x=standard_define([2,2],model,exprs,list(gr_i,0)) + x.graphics.in_implicit=Typein; + x.graphics.out_implicit=Typeout; + end +endfunction diff --git a/macros/Electrical/Inductor.sci b/macros/Electrical/Inductor.sci new file mode 100644 index 00000000..0bd2b7d2 --- /dev/null +++ b/macros/Electrical/Inductor.sci @@ -0,0 +1,69 @@ +// Scicos +// +// Copyright (C) INRIA - METALAU Project <scicos@inria.fr> +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// See the file ../license.txt +// + +function [x,y,typ]=Inductor(job,arg1,arg2) + // Copyright INRIA + x=[]; + y=[]; + typ=[]; + select job + case "set" then + x=arg1; + graphics=arg1.graphics; + exprs=graphics.exprs + model=arg1.model; + while %t do + [ok,L,exprs]=scicos_getvalue("Set Inductor block parameter",.. + "L (H)",list("vec",1),exprs) + if ~ok then + break, + end + model.rpar=L + model.equations.parameters(2)=list(L) + graphics.exprs=exprs + x.graphics=graphics; + x.model=model + break + end + case "define" then + model=scicos_model() + model.in=[1]; + model.out=[1]; + L=1.d-5 + model.rpar=L + model.sim="Inductor" + model.blocktype="c" + model.dep_ut=[%t %f] + mo=modelica(); + mo.model="Inductor" + mo.inputs="p"; + mo.outputs="n"; + mo.parameters=list("L",list(L)) + model.equations=mo; + exprs=string(L) + + gr_i=[] + + x=standard_define([2 0.9],model,exprs,list(gr_i,0)) + x.graphics.in_implicit=["I"] + x.graphics.out_implicit=["I"] + end +endfunction diff --git a/macros/Electrical/MOTOR.sci b/macros/Electrical/MOTOR.sci new file mode 100644 index 00000000..55756401 --- /dev/null +++ b/macros/Electrical/MOTOR.sci @@ -0,0 +1,49 @@ +// Scicos +// +// Copyright (C) INRIA - METALAU Project <scicos@inria.fr> +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// See the file ../license.txt +// + +function [x,y,typ]=MOTOR(job,arg1,arg2) + // exemple d'un bloc implicit, + // - sans entree ni sortie de conditionnement + // - avec deux entrees et une sortie de type implicit et de dimension 1 + // - avec des ports disposes en des positions non standard + + x=[]; + y=[]; + typ=[]; + select job + case "set" then + x=arg1; + case "define" then + model=scicos_model() + model.out=[1;1] + model.in=[1]; + model.sim="motor" + model.blocktype="c" + model.dep_ut=[%t %f] + gr_i=[]; + + + exprs="" + x=standard_define([2 2],model,exprs,gr_i) + x.graphics.out_implicit=["I";"I"] + x.graphics.in_implicit=["I"] + end +endfunction diff --git a/macros/Electrical/NMOS.sci b/macros/Electrical/NMOS.sci new file mode 100644 index 00000000..64a440e0 --- /dev/null +++ b/macros/Electrical/NMOS.sci @@ -0,0 +1,86 @@ +// Scicos +// +// Copyright (C) INRIA - METALAU Project <scicos@inria.fr> +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// See the file ../license.txt +// + +function [x,y,typ]=NMOS(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,W,L,Beta,Vt,K2,K5,dW,dL,RDS,exprs]=scicos_getvalue("Set NMOS Transistor block parameters",.. + ["Width [m]";.. + "Length [m]";.. + "Transconductance parameter [A/(V*V)]";.. + "Zero bias threshold voltage [V]";.. + "Bulk threshold parameter";.. + "Reduction of pinch-off region";.. + "Narrowing of channel [m]";.. + "Shortening of channel [m]";.. + "Drain-Source-Resistance [Ohm]"],.. + list("vec",-1,"vec",-1,"vec",-1,"vec",-1,"vec",-1,"vec",-1,"vec",-1,"vec",-1,"vec",-1),exprs) + + if ~ok then + break, + end + model.equations.parameters(2)=list(W,L,Beta,Vt,K2,K5,dW,dL,RDS) + graphics.exprs=exprs + x.graphics=graphics; + x.model=model + break + end + case "define" then + model=scicos_model() + W=20.e-6; + L=6.e-6; + Beta=0.041e-3; + Vt=0.8; + K2=1.144; + K5= 0.7311; + dW=-2.5e-6; + dL= -1.5e-6; + RDS=1.e+7; + + model.sim="NMOS" + model.blocktype="c" + model.dep_ut=[%t %f] + mo=modelica() + mo.model="NMOS"; + mo.outputs=["D";"B";"S"] + mo.inputs="G"; + mo.parameters=list(["W";"L";"Beta";"Vt";"K2";"K5";"dW";"dL";"RDS"],[W;L;Beta;Vt;K2;K5;dW;dL;RDS]) + model.equations=mo + model.in=ones(size(mo.inputs,"*"),1) + model.out=ones(size(mo.outputs,"*"),1) + exprs=[string(W);string(L);string(Beta);string(Vt);string(K2);string(K5);string(dW);string(dL);string(RDS)] + gr_i=[] + + x=standard_define([2 2],model,exprs,gr_i) + x.graphics.in_implicit=["I"] + x.graphics.out_implicit=["I";"I";"I"] + end +endfunction + + diff --git a/macros/Electrical/NPN.sci b/macros/Electrical/NPN.sci new file mode 100644 index 00000000..7be14930 --- /dev/null +++ b/macros/Electrical/NPN.sci @@ -0,0 +1,93 @@ +// Scicos +// +// Copyright (C) INRIA - METALAU Project <scicos@inria.fr> +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// See the file ../license.txt +// + +function [x,y,typ]=NPN(job,arg1,arg2) + // the automatically generated interface block for Modelica NPN.mo model + // - avec un dialogue de saisie de parametre + x=[]; + y=[]; + typ=[]; + select job + case "set" then + x=arg1; + graphics=arg1.graphics; + exprs=graphics.exprs + model=arg1.model; + x=arg1 + exprs=x.graphics.exprs + while %t do + [ok,Bf,Br,Is,Vak,Tauf,Taur,Ccs,Cje,Cjc,Phie,Me,Phic,Mc,Gbc,Gbe,Vt,EMinMax,exprs]=scicos_getvalue(["Set NPN block parameters:";""],["Bf : Forward beta";"Br : Reverse beta";"Is : Transport saturation current";"Vak : Early voltage (inverse), 1/Volt";"Tauf: Ideal forward transit time";"Taur: Ideal reverse transit time";"Ccs : Collector-substrat(ground) cap.";"Cje : Base-emitter zero bias depletion cap.";"Cjc : Base-coll. zero bias depletion cap.";"Phie: Base-emitter diffusion voltage";"Me : Base-emitter gradation exponent";"Phic: Base-collector diffusion voltage";"Mc : Base-collector gradation exponent";"Gbc : Base-collector conductance";"Gbe : Base-emitter conductance";"Vt : Voltage equivalent of temperature";"EMinmax: if x > EMinMax, the exp(x) is linearized"],list("vec",1,"vec",1,"vec",1,"vec",1,"vec",1,"vec",1,"vec",1,"vec",1,"vec",1,"vec",1,"vec",1,"vec",1,"vec",1,"vec",1,"vec",1,"vec",1,"vec",1),exprs) + if ~ok then + break, + end + x.model.equations.parameters(2)=list(Bf,Br,Is,Vak,Tauf,Taur,Ccs,Cje,Cjc,Phie,Me,Phic,Mc,Gbc,Gbe,Vt,EMinMax) + x.graphics.exprs=exprs + break + end + case "define" then + ModelName="NPN" + PrametersValue=[50;0.1;0;0.02;1.200D-10;5.000D-09;1.000D-12;4.000D-13;5.000D-13;0.8;0.4;0.8;0.333;1.000D-15;1.000D-15;0.02585;40] + ParametersName=["Bf";"Br";"Is";"Vak";"Tauf";"Taur";"Ccs";"Cje";"Cjc";"Phie";"Me";"Phic";"Mc";"Gbc";"Gbe";"Vt";"EMinMax"] + model=scicos_model() + Typein=[]; + Typeout=[]; + MI=[]; + MO=[] + P=[100,90,-2,0; 0,50,2,0; 100,10,-2,0] + PortName=["C";"B";"E"] + for i=1:size(P,"r") + if P(i,3)==1 then + Typein= [Typein; "E"]; + MI=[MI;PortName(i)]; + end + if P(i,3)==2 then + Typein= [Typein; "I"]; + MI=[MI;PortName(i)]; + end + if P(i,3)==-1 then + Typeout=[Typeout;"E"]; + MO=[MO;PortName(i)]; + end + if P(i,3)==-2 then + Typeout=[Typeout;"I"]; + MO=[MO;PortName(i)]; + end + end + model=scicos_model() + mo=modelica() + model.sim=ModelName; + mo.inputs=MI; + mo.outputs=MO; + model.rpar=PrametersValue; + mo.parameters=list(ParametersName,PrametersValue,zeros(ParametersName)); + exprs=["50";"0.1";"1.e-16";"0.02";"0.12e-9";"5e-9";"1e-12";"0.4e-12";"0.5e-12";"0.8";"0.4";"0.8";"0.333";"1e-15";"1e-15";"0.02585";"40"] + gr_i=[] + model.blocktype="c" + model.dep_ut=[%f %t] + mo.model=ModelName + model.equations=mo + model.in=ones(size(MI,"*"),1) + model.out=ones(size(MO,"*"),1) + x=standard_define([2,2],model,exprs,list(gr_i,0)) + x.graphics.in_implicit=Typein; + x.graphics.out_implicit=Typeout; + end +endfunction diff --git a/macros/Electrical/OpAmp.sci b/macros/Electrical/OpAmp.sci new file mode 100644 index 00000000..5f231669 --- /dev/null +++ b/macros/Electrical/OpAmp.sci @@ -0,0 +1,74 @@ +// Scicos +// +// Copyright (C) INRIA - METALAU Project <scicos@inria.fr> +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// See the file ../license.txt +// + +function [x,y,typ]=OpAmp(job,arg1,arg2) + x=[]; + y=[]; + typ=[]; + select job + case "set" then + x=arg1; + graphics=arg1.graphics; + exprs=graphics.exprs + model=arg1.model; + while %f do + [ok,OLGain,SatH,SatL,exprs]=scicos_getvalue("Set the Operational Amplifier parameters",.. + ["Open Loop Gain";"Positive saturation voltage";"Negative saturation voltage"],.. + list("vec",1,"vec",1,"vec",1),exprs); + if ~ok then + break, + end + model.equations.parameters(2)=list(OLGain,SatH,SatL) + graphics.exprs=exprs + x.graphics=graphics; + x.model=model + break + end + case "define" then + // OLGain=1000; + // SatH=10; + // SatL=-10; + // S=['OLGain';'SatH';'SatL']; + // Z=eval(S); + S=[]; + Z=[]; + model=scicos_model(); + model.sim="OpAmp"; + model.blocktype="c"; + model.dep_ut=[%t %f]; + mo=modelica(); + mo.model=model.sim; + mo.inputs=["in_p";"in_n"]; + mo.outputs=["out"]; + mo.parameters=list(S,Z); + model.equations=mo; + model.in=ones(size(mo.inputs,"*"),1); + model.out=ones(size(mo.outputs,"*"),1); + model.rpar=Z; + exprs=string(Z); + gr_i=[] + x=standard_define([3 5],model,exprs,gr_i) + x.graphics.in_implicit=["I";"I"] + x.graphics.out_implicit=["I"] + end +endfunction +// OpAmp + diff --git a/macros/Electrical/PMOS.sci b/macros/Electrical/PMOS.sci new file mode 100644 index 00000000..9219fe13 --- /dev/null +++ b/macros/Electrical/PMOS.sci @@ -0,0 +1,85 @@ +// Scicos +// +// Copyright (C) INRIA - METALAU Project <scicos@inria.fr> +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// See the file ../license.txt +// + +function [x,y,typ]=PMOS(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,W,L,Beta,Vt,K2,K5,dW,dL,RDS,exprs]=scicos_getvalue("Set PMOS Transistor parameters",.. + ["Width [m]";.. + "Length [m]";.. + "Transconductance parameter [A/(V*V)]";.. + "Zero bias threshold voltage [V]";.. + "Bulk threshold parameter";.. + "Reduction of pinch-off region";.. + "Narrowing of channel [m]";.. + "Shortening of channel [m]";.. + "Drain-Source-Resistance [Ohm]"],.. + list("vec",-1,"vec",-1,"vec",-1,"vec",-1,"vec",-1,"vec",-1,"vec",-1,"vec",-1,"vec",-1),exprs) + + if ~ok then + break, + end + model.equations.parameters(2)=list(W,L,Beta,Vt,K2,K5,dW,dL,RDS) + graphics.exprs=exprs + x.graphics=graphics; + x.model=model + break + end + case "define" then + model=scicos_model() + W=50.0e-6; + L=6.0e-6; + Beta=0.0105e-3; + Vt=-1; + K2=0.41; + K5=0.839; + dW=-2.5e-6; + dL=-2.1e-6; + RDS=1.e+7; + model.sim="PMOS" + model.blocktype="c" + model.dep_ut=[%t %f] + mo=modelica() + mo.model="PMOS"; + mo.outputs=["D";"B";"S"] + mo.inputs="G"; + mo.parameters=list(["W";"L";"Beta";"Vt";"K2";"K5";"dW";"dL";"RDS"],[W;L;Beta;Vt;K2;K5;dW;dL;RDS]) + model.equations=mo + model.in=ones(size(mo.inputs,"*"),1) + model.out=ones(size(mo.outputs,"*"),1) + exprs=[string(W);string(L);string(Beta);string(Vt);string(K2);string(K5);string(dW);string(dL);string(RDS)] + gr_i=[] + + x=standard_define([2 2],model,exprs,gr_i) + x.graphics.in_implicit=["I"] + x.graphics.out_implicit=["I";"I";"I"] + end +endfunction + + diff --git a/macros/Electrical/PNP.sci b/macros/Electrical/PNP.sci new file mode 100644 index 00000000..d52a335e --- /dev/null +++ b/macros/Electrical/PNP.sci @@ -0,0 +1,94 @@ +// Scicos +// +// Copyright (C) INRIA - METALAU Project <scicos@inria.fr> +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// See the file ../license.txt +// + +function [x,y,typ]=PNP(job,arg1,arg2) + // the automatically generated interface block for Modelica PNP.mo model + // - avec un dialogue de saisie de parametre + x=[]; + y=[]; + typ=[]; + select job + case "set" then + x=arg1; + graphics=arg1.graphics; + exprs=graphics.exprs + model=arg1.model; + x=arg1 + exprs=x.graphics.exprs + while %t do + [ok,Bf,Br,Is,Vak,Tauf,Taur,Ccs,Cje,Cjc,Phie,Me,Phic,Mc,Gbc,Gbe,Vt,EMinMax,exprs]=scicos_getvalue(["Set PNP block parameters:";"";],["Bf : Forward beta";"Br : Reverse beta";"Is : Transport saturation current";"Vak : Early voltage (inverse), 1/Volt";"Tauf: Ideal forward transit time";"Taur: Ideal reverse transit time";"Ccs : Collector-substrat(ground) cap.";"Cje : Base-emitter zero bias depletion cap.";"Cjc : Base-coll. zero bias depletion cap.";"Phie: Base-emitter diffusion voltage";"Me : Base-emitter gradation exponent";"Phic: Base-collector diffusion voltage";"Mc : Base-collector gradation exponent";"Gbc : Base-collector conductance";"Gbe : Base-emitter conductance";"Vt : Voltage equivalent of temperature";"EMinMax: if x > EMinMax, the exp(x) function is linearized"],list("vec",1,"vec",1,"vec",1,"vec",1,"vec",1,"vec",1,"vec",1,"vec",1,"vec",1,"vec",1,"vec",1,"vec",1,"vec",1,"vec",1,"vec",1,"vec",1,"vec",1),exprs) + if ~ok then + break, + end + x.model.equations.parameters(2)=list(Bf,Br,Is,Vak,Tauf,Taur,Ccs,Cje,Cjc,Phie,Me,Phic,Mc,Gbc,Gbe,Vt,EMinMax) + x.graphics.exprs=exprs + break + end + + case "define" then + ModelName="PNP" + PrametersValue=[50;0.1;0;0.02;1.200D-10;5.000D-09;1.000D-12;4.000D-13;5.000D-13;0.8;0.4;0.8;0.333;1.000D-15;1.000D-15;0.02585;40] + ParametersName=["Bf";"Br";"Is";"Vak";"Tauf";"Taur";"Ccs";"Cje";"Cjc";"Phie";"Me";"Phic";"Mc";"Gbc";"Gbe";"Vt";"EMinMax"] + model=scicos_model() + Typein=[]; + Typeout=[]; + MI=[]; + MO=[] + P=[100,90,-2,0;0,50,2,0;100,10,-2,0] + PortName=["C";"B";"E"] + for i=1:size(P,"r") + if P(i,3)==1 then + Typein= [Typein; "E"]; + MI=[MI;PortName(i)]; + end + if P(i,3)==2 then + Typein= [Typein; "I"]; + MI=[MI;PortName(i)]; + end + if P(i,3)==-1 then + Typeout=[Typeout;"E"]; + MO=[MO;PortName(i)]; + end + if P(i,3)==-2 then + Typeout=[Typeout;"I"]; + MO=[MO;PortName(i)]; + end + end + model=scicos_model() + mo=modelica() + model.sim=ModelName; + mo.inputs=MI; + mo.outputs=MO; + model.rpar=PrametersValue; + mo.parameters=list(ParametersName,PrametersValue,zeros(ParametersName)); + exprs=["50";"0.1";"1.e-16";"0.02";"0.12e-9";"5e-9";"1e-12";"0.4e-12";"0.5e-12";"0.8";"0.4";"0.8";"0.333";"1e-15";"1e-15";"0.02585";"40"] + gr_i=[] + model.blocktype="c" + model.dep_ut=[%f %t] + mo.model=ModelName + model.equations=mo + model.in=ones(size(MI,"*"),1) + model.out=ones(size(MO,"*"),1) + x=standard_define([2,2],model,exprs,list(gr_i,0)) + x.graphics.in_implicit=Typein; + x.graphics.out_implicit=Typeout; + end +endfunction diff --git a/macros/Electrical/PotentialSensor.sci b/macros/Electrical/PotentialSensor.sci new file mode 100644 index 00000000..619ac5ef --- /dev/null +++ b/macros/Electrical/PotentialSensor.sci @@ -0,0 +1,52 @@ +// Scicos +// +// Copyright (C) INRIA - METALAU Project <scicos@inria.fr> +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// See the file ../license.txt +// + +function [x,y,typ]= PotentialSensor(job,arg1,arg2) + // exemple d'un bloc implicit, + // - sans entree ni sortie de conditionnement + // - avec une entree et une sortie de type implicit et de dimension 1 + // - avec un dialogue de saisie de parametre + x=[]; + y=[]; + typ=[]; + select job + case "set" then + x=arg1; + case "define" then + model=scicos_model() + model.in=[1]; + model.out=[1]; + model.rpar=[] + model.sim="PotentialSensor" + model.blocktype="c" + model.dep_ut=[%t %f] + mo=modelica() + mo.model="PotentialSensor" + mo.inputs="p"; + mo.outputs=["v"] + model.equations=mo + gr_i=[] + + x=standard_define([2 2],model,"",list(gr_i,0)) + x.graphics.in_implicit=["I"] + x.graphics.out_implicit=["E"] + end +endfunction diff --git a/macros/Electrical/Resistor.sci b/macros/Electrical/Resistor.sci new file mode 100644 index 00000000..8bb798b0 --- /dev/null +++ b/macros/Electrical/Resistor.sci @@ -0,0 +1,70 @@ +// Scicos +// +// Copyright (C) INRIA - METALAU Project <scicos@inria.fr> +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// See the file ../license.txt +// + +function [x,y,typ]=Resistor(job,arg1,arg2) + // exemple d'un bloc implicit, + // - sans entree ni sortie de conditionnement + // - avec une entree et une sortie de type implicit et de dimension 1 + // - avec un dialogue de saisie de parametre + x=[]; + y=[]; + typ=[]; + select job + case "set" then + x=arg1; + graphics=arg1.graphics; + exprs=graphics.exprs + model=arg1.model; + while %t do + [ok,R,exprs]=scicos_getvalue("Set Resistor block parameter",.. + "R (ohm)",list("vec",1),exprs) + if ~ok then + break, + end + model.rpar=R + model.equations.parameters(2)=list(R) + graphics.exprs=exprs + x.graphics=graphics; + x.model=model + break + end + case "define" then + model=scicos_model() + R=0.01 + model.rpar=R + model.sim="resistor" + model.blocktype="c" + model.dep_ut=[%t %f] + mo=modelica() + mo.model="Resistor" + mo.inputs="p"; + mo.outputs="n"; + mo.parameters=list("R",list(R)) + model.equations=mo + model.in=ones(size(mo.inputs,"*"),1) + model.out=ones(size(mo.outputs,"*"),1) + exprs=string(R) + gr_i=[] + x=standard_define([2 1],model,exprs,list(gr_i,0)) + x.graphics.in_implicit=["I"] + x.graphics.out_implicit=["I"] + end +endfunction diff --git a/macros/Electrical/SineVoltage.sci b/macros/Electrical/SineVoltage.sci new file mode 100644 index 00000000..1baa222b --- /dev/null +++ b/macros/Electrical/SineVoltage.sci @@ -0,0 +1,79 @@ +// Scicos +// +// Copyright (C) INRIA - METALAU Project <scicos@inria.fr> +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// See the file ../license.txt +// + +function [x,y,typ]= SineVoltage(job,arg1,arg2) + // exemple d'un bloc implicit, + // - sans entree ni sortie de conditionnement + // - avec une entree et une sortie de type implicit et de dimension 1 + // - avec un dialogue de saisie de parametre + x=[]; + y=[]; + typ=[]; + select job + case "set" then + x=arg1; + graphics=arg1.graphics; + exprs=graphics.exprs + model=arg1.model; + while %t do + [ok,V,ph,frq,offset,start,exprs]=scicos_getvalue("Set voltage source parameter",.. + ["Amplitude (Volt)";"phase (rad)";"Frequency (Hz)";"Voltageoffset (V)";"Timeoffset (s)"],.. + list("vec",1,"vec",1,"vec",1,"vec",1,"vec",1),exprs) + if ~ok then + break, + end + model.rpar=[V;ph;frq;offset;start] + model.equations.parameters(2)=list(V,ph,frq,offset,start) + graphics.exprs=exprs + x.graphics=graphics; + x.model=model + break + end + case "define" then + model=scicos_model() + model.in=[1]; + model.out=[1]; + V=1 + ph=0 + frq=1 + offset=0 + start=0 + model.rpar=[V;ph;frq;offset;start] + model.sim="SineVoltage" + model.blocktype="c" + model.dep_ut=[%t %f] + mo=modelica() + mo.model="SineVoltage" + mo.inputs="p"; + mo.outputs="n"; + mo.parameters=list(["V";"phase";"freqHz";"offset";"startTime"],list(V,ph,frq,offset,start)) + model.equations=mo + + exprs=[string(V);string(ph);string(frq);string(offset);string(start)] + + gr_i=[] + + + x=standard_define([2 2],model,exprs,gr_i) + x.graphics.in_implicit=["I"] + x.graphics.out_implicit=["I"] + end +endfunction diff --git a/macros/Electrical/Switch.sci b/macros/Electrical/Switch.sci new file mode 100644 index 00000000..eb248f3f --- /dev/null +++ b/macros/Electrical/Switch.sci @@ -0,0 +1,72 @@ +// Scicos +// +// Copyright (C) INRIA - METALAU Project <scicos@inria.fr> +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// See the file ../license.txt +// + +function [x,y,typ]=Switch(job,arg1,arg2) + // exemple d'un bloc implicit, + // - sans entree ni sortie de conditionnement + // - avec une entree et une sortie de type implicit et de dimension 1 + // - avec un dialogue de saisie de parametre + x=[]; + y=[]; + typ=[]; + select job + case "set" then + x=arg1; + graphics=arg1.graphics; + exprs=graphics.exprs + model=arg1.model; + while %t do + [ok,Ron,Roff,exprs]=scicos_getvalue("Set non-ideal electrical switch parameters",.. + ["Resistance in On state (Ohm)";"Resistance in Off state (Ohm)"],list("vec",1,"vec",1),exprs) + if ~ok then + break, + end + model.equations.parameters(2)=list(Ron,Roff) + graphics.exprs=exprs + x.graphics=graphics; + x.model=model + break + end + case "define" then + model=scicos_model() + Ron=0.01; + Roff=1e5; + S=["Ron";"Roff"]; + Z=eval(S); + model.sim="Switch" + model.blocktype="c" + model.dep_ut=[%t %f] + mo=modelica() + mo.model=model.sim + mo.inputs=["p";"inp"]; + mo.outputs="n"; + mo.parameters=list(S,Z); + model.equations=mo + model.in=ones(size(mo.inputs,"*"),1) + model.out=ones(size(mo.outputs,"*"),1) + model.rpar=Z; + exprs=string(Z); + gr_i=[]; + x=standard_define([2 2],model,exprs,list(gr_i,0)) + x.graphics.in_implicit=["I";"E"] + x.graphics.out_implicit=["I"] + end +endfunction diff --git a/macros/Electrical/VVsourceAC.sci b/macros/Electrical/VVsourceAC.sci new file mode 100644 index 00000000..9e951afa --- /dev/null +++ b/macros/Electrical/VVsourceAC.sci @@ -0,0 +1,74 @@ +// Scicos +// +// Copyright (C) INRIA - METALAU Project <scicos@inria.fr> +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// See the file ../license.txt +// + +function [x,y,typ]=VVsourceAC(job,arg1,arg2) + // exemple d'un bloc implicit, + // - sans entree ni sortie de conditionnement + // - avec une entree et une sortie de type implicit et de dimension 1 + // - avec un dialogue de saisie de parametre + x=[]; + y=[]; + typ=[]; + select job + case "set" then + x=arg1; + graphics=arg1.graphics; + exprs=graphics.exprs + model=arg1.model; + while %t do + [ok,FR,exprs]=scicos_getvalue("Set voltage source parameter",.. + ["Frequency (Hz)"],.. + list("vec",-1),exprs) + if ~ok then + break, + end + model.rpar=[FR] + model.equations.parameters(2)=list(FR) + graphics.exprs=exprs + x.graphics=graphics; + x.model=model + break + end + case "define" then + model=scicos_model() + model.in=[1;1]; + model.out=[1]; + VA=220 + FR=50 + model.rpar=[FR] + model.sim="VVsourceAC" + model.blocktype="c" + model.dep_ut=[%t %f] + mo=modelica() + mo.model="VVsourceAC" + mo.inputs=["p","VA"]; + mo.outputs="n"; + mo.parameters=list(["f"],list(FR)) + model.equations=mo + + exprs=[string(FR)] + gr_i=[] + + x=standard_define([2 2],model,exprs,list(gr_i,0)) + x.graphics.in_implicit=["I","E"] + x.graphics.out_implicit=["I"] + end +endfunction diff --git a/macros/Electrical/VariableResistor.sci b/macros/Electrical/VariableResistor.sci new file mode 100644 index 00000000..74848529 --- /dev/null +++ b/macros/Electrical/VariableResistor.sci @@ -0,0 +1,51 @@ +// Scicos +// +// Copyright (C) INRIA - METALAU Project <scicos@inria.fr> +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// See the file ../license.txt +// + +function [x,y,typ]=VariableResistor(job,arg1,arg2) + // exemple d'un bloc implicit, + // - sans entree ni sortie de conditionnement + // - avec une entree et une sortie de type implicit et de dimension 1 + // - avec un dialogue de saisie de parametre + x=[]; + y=[]; + typ=[]; + select job + case "set" then + x=arg1; + case "define" then + model=scicos_model() + model.sim="VariableResistor" + model.blocktype="c" + model.dep_ut=[%t %f] + mo=modelica() + mo.model="VariableResistor" + mo.inputs=["p","R"]; + mo.outputs="n"; + model.equations=mo + model.in=ones(size(mo.inputs,"*"),1) + model.out=ones(size(mo.outputs,"*"),1) + exprs=[] + gr_i=[] + x=standard_define([2 2],model,exprs,list(gr_i,0)) + x.graphics.in_implicit=["I","E"] + x.graphics.out_implicit=["I"] + end +endfunction diff --git a/macros/Electrical/VoltageSensor.sci b/macros/Electrical/VoltageSensor.sci new file mode 100644 index 00000000..5e33531a --- /dev/null +++ b/macros/Electrical/VoltageSensor.sci @@ -0,0 +1,47 @@ +// Scicos +// +// Copyright (C) INRIA - METALAU Project <scicos@inria.fr> +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// See the file ../license.txt +// + +function [x,y,typ]=VoltageSensor(job,arg1,arg2) + x=[]; + y=[]; + typ=[]; + select job + case "set" then + x=arg1; + case "define" then + model=scicos_model() + model.in=1; + model.out=[1; 1]; + model.sim="VoltageSensor" + model.blocktype="c" + model.dep_ut=[%t %f] + mo=modelica() + mo.model="VoltageSensor" + mo.inputs="p"; + mo.outputs=["n";"v"] + model.equations=mo + exprs=[] + gr_i=[] + x=standard_define([2 2],model,exprs,list(gr_i,0)) + x.graphics.in_implicit=["I"] + x.graphics.out_implicit=["I";"E"] + end +endfunction diff --git a/macros/Electrical/VsourceAC.sci b/macros/Electrical/VsourceAC.sci new file mode 100644 index 00000000..da087294 --- /dev/null +++ b/macros/Electrical/VsourceAC.sci @@ -0,0 +1,74 @@ +// Scicos +// +// Copyright (C) INRIA - METALAU Project <scicos@inria.fr> +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// See the file ../license.txt +// + +function [x,y,typ]=VsourceAC(job,arg1,arg2) + // exemple d'un bloc implicit, + // - sans entree ni sortie de conditionnement + // - avec une entree et une sortie de type implicit et de dimension 1 + // - avec un dialogue de saisie de parametre + x=[]; + y=[]; + typ=[]; + select job + case "set" then + x=arg1; + graphics=arg1.graphics; + exprs=graphics.exprs + model=arg1.model; + while %t do + [ok,VA,FR,exprs]=scicos_getvalue("Set voltage source parameter",.. + ["Amplitude (Volt)";"Frequency (Hz)"],.. + list("vec",-1,"vec",-1),exprs) + if ~ok then + break, + end + model.rpar=[VA;FR] + model.equations.parameters(2)=list(VA,FR) + graphics.exprs=exprs + x.graphics=graphics; + x.model=model + break + end + case "define" then + model=scicos_model() + model.in=[1]; + model.out=[1]; + VA=220 + FR=50 + model.rpar=[VA;FR] + model.sim="VsourceAC" + model.blocktype="c" + model.dep_ut=[%t %f] + mo=modelica() + mo.model="VsourceAC" + mo.inputs="p"; + mo.outputs="n"; + mo.parameters=list(["VA";"f"],list(VA,FR)) + model.equations=mo + + exprs=[string(VA);string(FR)] + gr_i=[] + + x=standard_define([2 2],model,exprs,list(gr_i,0)) + x.graphics.in_implicit=["I"] + x.graphics.out_implicit=["I"] + end +endfunction |