Guest User

Untitled

a guest
May 22nd, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. component CPE
  2.  
  3. % The rest of the comment shows up as the component explanation.
  4. nodes %conserving ports
  5. p = foundation.electrical.electrical; % +:top
  6. n = foundation.electrical.electrical; % -:bottom
  7.  
  8.  
  9. end
  10. nodes(Access=private)
  11. n1 = foundation.electrical.electrical;
  12. n2 = foundation.electrical.electrical;
  13.  
  14. end
  15. % These ports show up in the block diagram. The comments immediately after the domain declaration controls the displayed name and location of the ports in the block diagram
  16. parameters
  17. Rs = { 1, 'Ohm' }; % Rs
  18. Rt = {2, 'Ohm'}; % Rt
  19. Q = {2, '1'}; % Q is unitless
  20. Aw = {2, '1'}; % Aw is unitless
  21.  
  22. end
  23.  
  24. variables(Access=public)
  25. i = { 0, 'A' }; % Current
  26. % v = { 0, 'V' }; % Voltage
  27. Zcpe = { 1, 'ohm' }; %
  28. Zw = { 0.75, 'ohm' }; %
  29.  
  30. end
  31.  
  32. function setup
  33.  
  34. n1.v = {value={0, 'V'},priority=priority.high};
  35. n2.v = {value={0, 'K'},priority=priority.high};
  36.  
  37. end
  38.  
  39. % Parameter validation. These branches are half of the equations,
  40. %the other half go in the equations section, there can only be an
  41. % equal number of branch equations + equations = variables.
  42. branches
  43. i1 : p.i -> n1.i;
  44. i3 : n1.i -> n.i;
  45. i2 : n1.i -> n2.i;
  46. % i2a : n2.i -> n.i; %may not need this one, might want to eliminate node n2 and go straght from n1 to n
  47.  
  48.  
  49.  
  50. end
  51.  
  52.  
  53.  
  54. equations
  55.  
  56. let
  57.  
  58.  
  59.  
  60. v = p.v - n1.v;
  61. v2 = n1.v - n.v;
  62. v3 = n1.v - n.v;
  63. in
  64.  
  65. v == i1*Rs; % Voltage equation
  66. i1 == i2 + i3;
  67. Zcpe*Zcpe * -Q*w == 1; %This will also need to be converted to a differential equation this is just an example
  68. %The equation is rewritten as follows Zcpe == 1/Q/(j*w);
  69. %to this by squaring both sides Zcpe*Zcpe == -1/(Q*Q*w*w); to this Zcpe*Zcpe *(Q*Q*w*w) ==1;
  70.  
  71. %write the Zw equation the same but square it twice Zw*Zw*Zw*Zw == -4*Aw*Aw*Aw*Aw/(w*W);
  72. Zw*Zw*Zw*Zw*w*w == -4*Aw*Aw*Aw*Aw; %This will also need to be converted to a differential equation this is just an example
  73. v2 == i2*Zcpe;
  74. v3 == i3*(Rt+Zw);
  75.  
  76.  
  77. end
  78.  
  79. end % equations
  80.  
  81.  
  82. end %component I miss the curly braces...
Add Comment
Please, Sign In to add comment