There are two ways of adding a series resistance. First, you can simply add an internal node and an additional branch. For example, consider this
nonlinear capacitor Code:module varactor(p, n);
inout p, n;
electrical p, n;
parameter real c0 = 1p from (0:inf); // nominal capacitance (F)
parameter real c1 = 0.5p from [0:c0); // maximum capacitance change from nominal (F)
parameter real v0 = 0; // voltage for nominal capacitance (V)
parameter real v1 = 1 from (0:inf); // voltage change for maximum capacitance (V)
real q, v;
analog begin
v = V(p,n);
q = c0∗v + c1∗v1∗ln(cosh((v – v0)/v1));
I(p, n) <+ ddt(q);
end
endmodule
You can modify this model to add a series resistance as follows:
Code:module varactor(p, n);
inout p, n;
electrical p, n, int;
parameter real c0 = 1p from (0:inf); // nominal capacitance (F)
parameter real c1 = 0.5p from [0:c0); // maximum capacitance change from nominal (F)
parameter real v0 = 0; // voltage for nominal capacitance (V)
parameter real v1 = 1 from (0:inf); // voltage change for maximum capacitance (V)
parameter real r = 0 from [0:inf); // series resistance (Ohms)
branch (p, int) res;
branch (int, n) cap;
real q, v;
analog begin
v = V(cap);
q = c0∗v + c1∗v1∗ln(cosh((v – v0)/v1));
I(cap) <+ ddt(q);
V(res) <+ r * I(res);
end
endmodule
Alternatively, you use an implicit formulation:
Code:module varactor(p, n);
inout p, n;
electrical p, n, int;
parameter real c0 = 1p from (0:inf); // nominal capacitance (F)
parameter real c1 = 0.5p from [0:c0); // maximum capacitance change from nominal (F)
parameter real v0 = 0; // voltage for nominal capacitance (V)
parameter real v1 = 1 from (0:inf); // voltage change for maximum capacitance (V)
parameter real r = 0 from [0:inf); // series resistance (Ohms)
real q, v;
analog begin
v = V(p,n) - r*I(p,n)
q = c0∗v + c1∗v1∗ln(cosh((v – v0)/v1));
I(p, n) <+ ddt(q);
end
endmodule
-Ken