# How to create a custom capacitor with changing distance between capacitor plates?

1 view (last 30 days)
Alexander Vasilev on 7 May 2021
Commented: David John on 3 Aug 2021
Hello.
How to create a custom capacitor with changing distance between capacitor plates?
Excuse for troubling.
component capacitor
nodes
p = foundation.electrical.electrical; % +:top
n = foundation.electrical.electrical; % -:bottom
end
inputs
d2 = { 0.01, 'mm' }; % :bottom
end
parameters
d1 = { 0.01, 'mm' };
C0 = { 1, 'F' }; % Nominal capacitance C0 at V=0
Cv = { 0.2, 'F/V'}; % Rate of change of C with voltage V
R = {2, 'Ohm' }; % Effective series resistance
Rd = {500, 'Ohm' }; % Self-discharge resistance
end
variables
i = { 0, 'A' }; % Current
vc = {value = { 0, 'V' }, priority = priority.high}; % Capacitor voltage
end
branches
i : p.i -> n.i; % Through variable i from node p to node n
end
equations
assert(C0 > 0)
assert(R > 0)
assert(Rd > 0)
let
v = p.v-n.v; % Across variable v from p to n
in
v == vc;
i == (C0*k)*der(vc*(d2/d1));
% k = e*e0*S/d2
end
end
end
Alexander Vasilev on 7 May 2021
v == vc*(d2/d1);
i == C0*der(v);
% k = e*e0*S/d2
Don't work too.
Voltage does not increase.
For simplicity, I have not changed the capacity yet.

David John on 3 Aug 2021
If you want to change the capacitance based on an input, you can have something like
i == C0*d1/d2*vc.der;
I'm not sure what you mean when you say that "the voltage does not increase". If you can share your test model, I can probably comment on that as well.
David John on 3 Aug 2021
By the way, if you have Simscape Electrical, then there is a "Variable Capacitor" block that does something similar to what you want.