Guest User

Untitled

a guest
Apr 20th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.64 KB | None | 0 0
  1.  
  2. using VTB.Interfaces;
  3. using VTB.Framework.ComponentDevelopment;
  4. using SignalBackPlane;
  5. using SwitchModel = SysEDA.Components.Natural.CoreModels.IdealSwitch;
  6. using SnubberModel = SysEDA.Components.Natural.CoreModels.SeriesRCCoreModel;
  7.  
  8. namespace SysEDA.Components.Natural
  9. {
  10. /// <summary>
  11. /// Summary
  12. /// </summary>
  13. [ComponentMetaData("SysEDA.Components.Natural.Electrical.PowerElectronics.Inverters.InverterControlled3Ph1L.vte")]
  14. public class InverterControlled : NaturalSignalEngine
  15. {
  16. #region Data Members
  17. private IInteractionPoint m_oPositiveDC;
  18. private IInteractionPoint m_oNegativeDC;
  19. private IInteractionPoint m_oA;
  20. private IInteractionPoint m_oB;
  21. private IInteractionPoint m_oC;
  22. private IInteractionPoint m_oGates;
  23.  
  24. private IInteractionPoint m_oACPower;
  25. private IInteractionPoint m_oCurrentA;
  26. private IInteractionPoint m_oCurrentB;
  27. private IInteractionPoint m_oCurrentC;
  28. private IInteractionPoint m_oDCCurrent;
  29. private IInteractionPoint m_oDCVoltage;
  30. private IInteractionPoint m_oDCPower;
  31. private IInteractionPoint m_oPowerA;
  32. private IInteractionPoint m_oPowerB;
  33. private IInteractionPoint m_oPowerC;
  34. private IInteractionPoint m_oVoltageA;
  35. private IInteractionPoint m_oVoltageB;
  36. private IInteractionPoint m_oVoltageC;
  37.  
  38. private IInteractionPoint m_oSnubberResistance;
  39. private IInteractionPoint m_oSnubberCapacitance;
  40.  
  41. private SwitchModel m_oS1;
  42. private SwitchModel m_oS2;
  43. private SwitchModel m_oS3;
  44. private SwitchModel m_oS4;
  45. private SwitchModel m_oS5;
  46. private SwitchModel m_oS6;
  47.  
  48. private SnubberModel m_oSnub1;
  49. private SnubberModel m_oSnub2;
  50. private SnubberModel m_oSnub3;
  51. private SnubberModel m_oSnub4;
  52. private SnubberModel m_oSnub5;
  53. private SnubberModel m_oSnub6;
  54.  
  55.  
  56. private double[,] m_dGates;
  57. private bool[] m_bGates;
  58.  
  59. private double m_dSnubberResistance;
  60. private double m_dSnubberCapacitance;
  61.  
  62. #endregion
  63.  
  64. #region Constructor
  65. public InverterControlled(IEntity oEntity)
  66. : base(oEntity, 2)
  67. {
  68. m_oPositiveDC = GetIP("PositiveDC");
  69. m_oNegativeDC = GetIP("NegativeDC");
  70. m_oA = GetIP("A");
  71. m_oB = GetIP("B");
  72. m_oC = GetIP("C");
  73. m_oGates = GetIP("Gates");
  74.  
  75. m_oSnubberResistance = GetIP("SnubberResistance");
  76. m_oSnubberCapacitance = GetIP("SnubberCapacitance");
  77.  
  78. m_oACPower = GetIP("ACPower");
  79. m_oCurrentA = GetIP("CurrentA");
  80. m_oCurrentB = GetIP("CurrentB");
  81. m_oCurrentC = GetIP("CurrentC");
  82. m_oDCCurrent = GetIP("DCCurrent");
  83. m_oDCVoltage = GetIP("DCVoltage");
  84. m_oDCPower = GetIP("DCPower");
  85. m_oPowerA = GetIP("PowerA");
  86. m_oPowerB = GetIP("PowerB");
  87. m_oPowerC = GetIP("PowerC");
  88. m_oVoltageA = GetIP("VoltageA");
  89. m_oVoltageB = GetIP("VoltageB");
  90. m_oVoltageC = GetIP("VoltageC");
  91.  
  92. m_oS1 = new SwitchModel(m_oA, m_oPositiveDC);
  93. m_oS2 = new SwitchModel(m_oNegativeDC, m_oA);
  94. m_oS3 = new SwitchModel(m_oB, m_oPositiveDC);
  95. m_oS4 = new SwitchModel(m_oNegativeDC, m_oB);
  96. m_oS5 = new SwitchModel(m_oC, m_oPositiveDC);
  97. m_oS6 = new SwitchModel(m_oNegativeDC, m_oC);
  98.  
  99. m_oSnub1 = new SnubberModel(m_oA, m_oPositiveDC);
  100. m_oSnub2 = new SnubberModel(m_oNegativeDC, m_oA);
  101. m_oSnub3 = new SnubberModel(m_oB, m_oPositiveDC);
  102. m_oSnub4 = new SnubberModel(m_oNegativeDC, m_oB);
  103. m_oSnub5 = new SnubberModel(m_oC, m_oPositiveDC);
  104. m_oSnub6 = new SnubberModel(m_oNegativeDC, m_oC);
  105.  
  106. //AddCoreModel(m_oS1);
  107. //AddCoreModel(m_oS2);
  108. //AddCoreModel(m_oS3);
  109. //AddCoreModel(m_oS4);
  110. //AddCoreModel(m_oS5);
  111. //AddCoreModel(m_oS6);
  112.  
  113. AddCoreModels(m_oS1, m_oS2, m_oS3, m_oS4, m_oS5, m_oS6);
  114.  
  115. AddCoreModels(m_oSnub1, m_oSnub2, m_oSnub3, m_oSnub4, m_oSnub5, m_oSnub6);
  116.  
  117. //AddCoreModels(m_oSnub1);
  118. //AddCoreModels(m_oSnub2);
  119. //AddCoreModels(m_oSnub3);
  120. //AddCoreModels(m_oSnub4);
  121. //AddCoreModels(m_oSnub5);
  122. //AddCoreModels(m_oSnub6);
  123.  
  124. m_bGates = new bool[6];
  125. }
  126. #endregion
  127.  
  128. #region Engine
  129.  
  130. public override void OnSimulationStart()
  131. {
  132. base.OnSimulationStart();
  133.  
  134. m_oS1.IsClosed = true;
  135. m_oS2.IsClosed = true;
  136. m_oS3.IsClosed = true;
  137. m_oS4.IsClosed = true;
  138. m_oS5.IsClosed = true;
  139. m_oS6.IsClosed = true;
  140. }
  141.  
  142. public override void OnRunTimeChange(bool bParameterChanged)
  143. {
  144. base.OnRunTimeChange(bParameterChanged);
  145.  
  146. if (bParameterChanged)
  147. {
  148. m_dSnubberCapacitance = GetIPValue(m_oSnubberCapacitance);
  149. m_dSnubberResistance = GetIPValue(m_oSnubberResistance);
  150.  
  151. m_oSnub1.Resistance = m_dSnubberResistance;
  152. m_oSnub2.Resistance = m_dSnubberResistance;
  153. m_oSnub3.Resistance = m_dSnubberResistance;
  154. m_oSnub4.Resistance = m_dSnubberResistance;
  155. m_oSnub5.Resistance = m_dSnubberResistance;
  156. m_oSnub6.Resistance = m_dSnubberResistance;
  157.  
  158. m_oSnub1.Capacitance = m_dSnubberCapacitance;
  159. m_oSnub2.Capacitance = m_dSnubberCapacitance;
  160. m_oSnub3.Capacitance = m_dSnubberCapacitance;
  161. m_oSnub4.Capacitance = m_dSnubberCapacitance;
  162. m_oSnub5.Capacitance = m_dSnubberCapacitance;
  163. m_oSnub6.Capacitance = m_dSnubberCapacitance;
  164. }
  165. }
  166.  
  167. public override void SignalStep()
  168. {
  169. m_oGates.Primitive.GetData(out m_dGates);
  170.  
  171. if (m_dGates.GetLength(0) > 1)
  172. {
  173. for (int i = 0; i < 6; i++)
  174. {
  175. m_bGates[i] = false;
  176. if(i < m_dGates.GetLength(0))
  177. {
  178. if (m_dGates[i, 0] > 0.0)
  179. {
  180. m_bGates[i] = true;
  181. }
  182. }
  183. }
  184. }
  185. else // try other dimension:
  186. {
  187. for (int i = 0; i < 6; i++)
  188. {
  189. m_bGates[i] = false;
  190. if (i < m_dGates.GetLength(1))
  191. {
  192. if (m_dGates[0, i] > 0.0)
  193. {
  194. m_bGates[i] = true;
  195. }
  196. }
  197. }
  198. }
  199.  
  200. m_oS1.IsClosed = m_bGates[0];
  201. m_oS2.IsClosed = m_bGates[1];
  202. m_oS3.IsClosed = m_bGates[2];
  203. m_oS4.IsClosed = m_bGates[3];
  204. m_oS5.IsClosed = m_bGates[4];
  205. m_oS6.IsClosed = m_bGates[5];
  206. }
  207.  
  208.  
  209. public override void PostStep()
  210. {
  211. double dVoltageDC = GetAcrossDifference(m_oPositiveDC, m_oNegativeDC);
  212. double dCurrentDC = GetThrough(m_oPositiveDC);
  213.  
  214. double dVoltageA = GetAcross(m_oA);
  215. double dVoltageB = GetAcross(m_oB);
  216. double dVoltageC = GetAcross(m_oC);
  217. double dCurrentA = -GetThrough(m_oA);
  218. double dCurrentB = -GetThrough(m_oB);
  219. double dCurrentC = -GetThrough(m_oC);
  220.  
  221. double dPowerA = dVoltageA * dCurrentA;
  222. double dPowerB = dVoltageB * dCurrentB;
  223. double dPowerC = dVoltageC * dCurrentC;
  224.  
  225. SetIPValue(m_oDCVoltage, dVoltageDC);
  226. SetIPValue(m_oDCCurrent, dCurrentDC);
  227. SetIPValue(m_oDCPower, dVoltageDC * dCurrentDC);
  228.  
  229. SetIPValue(m_oVoltageA, dVoltageA);
  230. SetIPValue(m_oVoltageB, dVoltageB);
  231. SetIPValue(m_oVoltageC, dVoltageC);
  232. SetIPValue(m_oCurrentA, dCurrentA);
  233. SetIPValue(m_oCurrentB, dCurrentB);
  234. SetIPValue(m_oCurrentC, dCurrentC);
  235. SetIPValue(m_oPowerA, dPowerA);
  236. SetIPValue(m_oPowerB, dPowerB);
  237. SetIPValue(m_oPowerC, dPowerC);
  238. SetIPValue(m_oACPower, dPowerA + dPowerB + dPowerC);
  239.  
  240. }
  241. #endregion
  242.  
  243. }
  244. }
Add Comment
Please, Sign In to add comment