Message Boards Message Boards

0
|
6191 Views
|
1 Reply
|
1 Total Likes
View groups...
Share
Share this post:

Connect WSM components within Mathematica?

Friends from the SystemModeler

I have created a WSM model in Mathematica, In the simulation center, I have connected a Pulse source that drivens the dynamics of the model. The responses are as expected. I wanted to do the connection within Mathematica like this

BoostParmeters = {Rs -> 0.001, Rd -> 0.001, RLoad -> 12.5, Vd -> 0.8, 
   C1 -> 0.0002, L -> 0.0002, Vin -> 18};
(*System equations*)

eqns1 = {Derivative[1][iL][t] == 
    Vin/L - (Rs iL[t])/L - (Vd S[t])/L - (Rd iL[t] S[t])/L + (
     Rs iL[t] S[t])/L - (S[t] vC[t])/L, 
   Derivative[1][vC][t] == (iL[t] S[t])/C1 - vC[t]/(C1 RLoad)};
(*The connections*)

conns = {S[t] \[Element] "Modelica.Blocks.Interfaces.RealInput", 
   iL[t] \[Element] "Modelica.Blocks.Interfaces.RealOutput"};
BoostWSM = 
  CreateSystemModel["BoostCCM", eqns1, t, 
   conns, <|"InitialValues" -> Thread[{iL -> 0, vC -> 0}], 
    "ParameterValues" -> BoostParmeters|>];
(*Source*)
pwm2 = 
  SystemModel[
   "Modelica.Blocks.Sources.Pulse", <|"ModelName" -> "pwmSignal", 
    "ParameterValues" -> {"width" -> 40, "period" -> 0.000100}|>];
(*Connecting the systems*)
Boost2 = 
 ConnectSystemModelComponents[{BoostWSM, 
   pwm2}, {"Pulse.y" -> "BoostCCM.S"}]

After this, it seems that the connection has been done. However, the siumlation

Simu = SystemModelSimulate[Boost2, {0, 0.02}];
SystemModelPlot[Simu, {"iL", "vC"}, PlotMarkers -> None]

will fail. I am not sure what I have done wrong. Could someone help me with this?

Cheers Jesus

This worked !!

BoostParmeters = {Rs -> 0.001, Rd -> 0.001, RLoad -> 12.5, Vd -> 0.8, 
   C1 -> 0.0002, L -> 0.0002, Vin -> 18};
(*System equations*)

eqns1 = {Derivative[1][iL][t] == 
    Vin/L - (Rs iL[t])/L - (Vd S[t])/L - (Rd iL[t] S[t])/L + (
     Rs iL[t] S[t])/L - (S[t] vC[t])/L, 
   Derivative[1][vC][t] == (iL[t] S[t])/C1 - vC[t]/(C1 RLoad)};
(*The connections*)

conns = {S[t] \[Element] "Modelica.Blocks.Interfaces.RealInput", 
   iL[t] \[Element] "Modelica.Blocks.Interfaces.RealOutput"};
BoostWSM = 
  CreateSystemModel["BoostCCM", eqns1, t, 
   conns, <|"InitialValues" -> {iL -> 0, vC -> 0}, 
    "ParameterValues" -> BoostParmeters|>];
(*Source*)
pwm2 = 
  SystemModel[
   "Modelica.Blocks.Sources.Pulse", <|"ModelName" -> "pwmSignal", 
    "ParameterValues" -> {"width" -> 40, "period" -> 0.000100}|>];
(*Connecting the systems*)

elementos = {"boost3" \[Element] BoostWSM, "pwm" \[Element] pwm2};
Boost2 = ConnectSystemModelComponents[
  elementos, {"pwm.y" -> "boost3.S"}]
Simu = SystemModelSimulate[Boost2, {0, 0.02}];
SystemModelPlot[Simu, {"boost3.iL", "boost3.vC"}, PlotMarkers -> None,
  PlotRange -> All]

I hope my replay to myself could be useful for someone else. Thanks anyway! Jesús

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract