1
\$\begingroup\$

I want to use a CPE in my circuit, but I can't find a CPE in the Simscape library, so I want to make a CEP with the Simscape language. What can I do? I just want to build this circuit,like the picture,the impedacne is a complex number,I can't express it's imaginary part. enter image description here

\$\endgroup\$
  • 1
    \$\begingroup\$ Hi @C.Bing, welcome to EE.SE. This is not how you should write a question. You have repeated same sentence three times without any information or context. You have to formulate your question properly and you have to show some effort to get proper help. \$\endgroup\$ – Hazem May 21 '18 at 8:51
  • \$\begingroup\$ I am sorry for my expression,I will try my best to learn how to make a good question. \$\endgroup\$ – C.Bing May 22 '18 at 9:50
1
\$\begingroup\$

You can write a custom component:

enter image description here

component CPE

%   The rest of the comment shows up as the component explanation.
nodes %conserving ports
 p = foundation.electrical.electrical; % +:top
 n = foundation.electrical.electrical; % -:bottom


end
nodes(Access=private)
 n1 = foundation.electrical.electrical; 
 n2 = foundation.electrical.electrical; 

end
% 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
parameters
 Rs = { 1, 'Ohm' }; % Rs
 Rt = {2, 'Ohm'};   % Rt
 Q = {2, '1'};   % Q is unitless 
 Aw = {2, '1'};   % Aw is unitless 

end

variables(Access=public)
 i = { 0, 'A' };  % Current
%  v = { 0, 'V' };  % Voltage
 Zcpe = { 1, 'ohm' }; % 
 Zw = { 0.75, 'ohm' }; % 

end

function setup  

    n1.v =  {value={0, 'V'},priority=priority.high};
    n2.v =  {value={0, 'K'},priority=priority.high};

end

% Parameter validation. These branches are half of the equations, 
%the other half go in the equations section, there can only be an
% equal number of branch equations + equations = variables.
branches
    i1  : p.i -> n1.i;
    i3  : n1.i -> n.i;
    i2  : n1.i -> n2.i;
%   i2a  : n2.i -> n.i; %may not need this one, might want to eliminate node n2 and go straght from n1 to n



end



equations

 let 



     v = p.v - n1.v;
     v2 = n1.v - n.v;
     v3 = n1.v - n.v;
 in

    v ==  i1*Rs; % Voltage equation
    i1 == i2 + i3;
    Zcpe*Zcpe * -Q*w ==  1; %This will also need to be converted to a differential equation this is just an example
    %The equation is rewritten as follows Zcpe == 1/Q/(j*w); 
    %to this by squaring both sides Zcpe*Zcpe == -1/(Q*Q*w*w); to this Zcpe*Zcpe *(Q*Q*w*w) ==1; 

    %write the Zw equation the same but square it twice Zw*Zw*Zw*Zw == -4*Aw*Aw*Aw*Aw/(w*W);
    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
    v2 == i2*Zcpe;
    v3 == i3*(Rt+Zw);


 end

end % equations


end %component  I miss the curly braces...

This code isn't even close to being workable, remember, this took a small amount of my time so I hope you have some appreciation for it (and vote accordingly). Writing custom components isn't easy and it will take a few weeks of pulling your hair out in frustration before you understand the concepts to make this work. There is one concept I don't understand that you will need to fill in, and thats adding in the differential equations, this custom component is an example. Simscape does do s-paramters

I had to pour through the documentation about 4 times and try simple examples before I could work my way up to a full component with many nodes. The first thing I would do is get only the Zcpe component working and tested as a custom component, then work your way up. If you can get Zcpe, you can get everything working.

\$\endgroup\$
  • \$\begingroup\$ First of all,thank you very much for your help.It can be seen that took your time and I am very appreciate for this.I don't know if you understand the Randles’ circuit,I just want to build a equivalent circuit of the electrode with Simscape. Zcpe is the impedance of the frequency dependant double layer capacitance (a constant phase element).Zw is the Warburg impedance.Finally, thanks again for your help. \$\endgroup\$ – C.Bing May 23 '18 at 9:40
  • \$\begingroup\$ You cannot do this in simscape, there are no components with the parameters you desire, you'll have to write a custom component. I know that this might come at a dissapointment, but it is the way. There may be a way to simulate this in simulink if you can convert it to a transfer function with laplace, but it doesn't look like this would be possible. \$\endgroup\$ – Voltage Spike May 23 '18 at 15:22
  • \$\begingroup\$ +1 for the great effort \$\endgroup\$ – Hazem May 23 '18 at 22:25
  • \$\begingroup\$ IF you've ever written a custom component there are several tricks in this one you may benefit from. \$\endgroup\$ – Voltage Spike May 23 '18 at 22:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.