# RC Circuit - Numerical time domain analysis

Status
Not open for further replies.

#### Osman Ceylan

##### Junior Member level 1 In a RC circuit, if the voltage source is a sinusoidal source, I found the given equation. C is constant.
I tried to solve this problem in time domain. So, I use a source in an EDA tool. I found the current in time. I know the voltage. I use simple numerical derivaton df(x)=[f(x2)-f(x1)]/(x2-x1). In this case, derivation is almost zero at the peak and bottom of the sinus. So, capacitance goes infinite. What am I doing wrong? #### FvM

##### Super Moderator
Staff member In this case, derivation is almost zero at the peak and bottom of the sinus. So, capacitance goes infinite.
C being a constant is a prerequisite of the differential equation.

You first have to find a steady state solution for i(t). You already know that it's sinusoidal, so you'll determine the magnitude and phase that allows for a constant C. Then calculate C.

#### Osman Ceylan

##### Junior Member level 1 Consider the C is zero. I mean there is no condition at the begining. If I solve the i(t), there is no requirement for the numerical solution. I would like to solve in Matlab without any pre-calculation. It may be more complex circuit.

- - - Updated - - -

Vs(t) may also be a composition of several sinusoidal signal. cos(wt)+cos(2wt) etc. So it becomes a very hard differential equation.

##### Super Moderator
Staff member Current always leads voltage by 90 degrees in a capacitor (when you apply AC sinewave). This is true for every capacitor you or I will ever test.

When you measure voltage, it is important which component you are reading across. The voltage amplitude peaks at different times, across different components in the circuit. Of course this goes against our intuitive sense.

However your instantaneous Ampere reading will be the same wherever you measure it, whether through supply, capacitor, or resistor. Of course this is easy for our intuitive sense to grasp.

It is only across the ohmic resistor, that V relates to A in linear proportion. This is not so in the other components.

#### FvM

##### Super Moderator
Staff member Consider the C is zero.
That's in fact an easy case, i(t) will be zero as well.

Vs(t) may also be a composition of several sinusoidal signal. cos(wt)+cos(2wt) etc. So it becomes a very hard differential equation.
Yes, and not a particularly meaningful job. Solving steady state for linear AC networks can be done much easier.

#### Osman Ceylan

##### Junior Member level 1 I use a software to find voltage and current values. (You can see it.) Voltage shape is not very good, because capacitor is not ideal, its value changes by time. So, I am trying to find a capacitance value which depends on time, such as C(t). So, I am trying a basic numerical method. I can not solve any equation, because I do not have any equation. I have only measurements.
I have i(t) and v(t), so it looks very easy. However it does not work. What is wrong? ##### Super Moderator
Staff member Your waveforms appear to be textbook perfect. Almost anyway.

Current graph extends into the positive region a little.
It is slightly asymmetric (rises faster than it falls).
It leads the voltage graph by a little less than theory dictates.

These are small anomalies. The sort of things that might be accounted for by ESR changes in the capacitor depending on current flow, resistance changes in the power supply during each sine cycle, or the high frequency (8 GHz) acting on real components.

Are you testing real components?

- - - Updated - - - #### FvM

##### Super Moderator
Staff member I am trying to find a capacitance value which depends on time, such as C(t).
This creates a system of nonlinear differential equations, and also contradicts the assumption in post #1 (i(t) is differntial of capacitor voltage).

Nonlinear differntial equations can be analytically solved only in special cases, means you have to rely on numerical methods.

#### Osman Ceylan

##### Junior Member level 1 BradtheRad; This is a computer analysis output. I am trying to understand my circuit's response, so I need to find capacitance. It does not matter, because if we use your graphs, as you see derivation is zero at the top and bottom of the sinus. So, in a numerical solution C valuse goes verh high. I am trying to understand the problem on numerical solution.

FvM; Yes, it is a nonlinear capacitor. Before the nonlinear solution, I am trying the linear function. My basic numerical solution is not working. It is only OK for the decreasing or increasin part of the signal. In normal case, C should be constant, right?

Maybe I need to ask this question to a mathematical forum #### D.A.(Tony)Stewart I(t) goes to zero as freq. goes to zero and also di/dt goes to zero, for any value of C.

#### Osman Ceylan

##### Junior Member level 1 So, is circuit theory wrong? #### _Eduardo_

##### Full Member level 5 So, is circuit theory wrong? No, your electrical skills are wrong If C variable, then is not true.

Must be:

$V_c(t) = V_s(t)-RI(t) \\ I(t)=\frac{d}{dt}(C(t) V_c(t))$

Integrating both member

$\int_0^t{I(t)dt = C(t) V_c(t) - C(0) V_c(0) = C(t) V_c(t) + K$

Naming $II(t)=\int_0^t{I(t)dt$ (by numerical methods)

Then $K = II(t_z)$ where $t_z$ is the time when $V_c=0$

• ferdem and FvM

Points: 2

### ferdem

Points: 2

#### Osman Ceylan

##### Junior Member level 1 ##### Super Moderator
Staff member Anomalies appear when you apply sinewaves to a capacitor.

This simulation tells more of the story than my previous screenshot (post #7). No two waveforms are aligned (except the R voltage and current).

Current leads both supply V and capacitor V.

Current peaks when capacitor V is zero.
Capacitor V peaks when current is zero.

These observations may or may not explain how the math works.

Or else, math might be able to explain what is happening, and I can see it in action... Nevertheless my mind still has trouble getting a handle on it.

#### _Eduardo_

##### Full Member level 5 I know the variable C equation. Consider that C is constant. So this is true:
View attachment 116168
Denominator still goes zero... So, C is not constant? How can we verify this equation?

If your circuit perfectly match your proposed model (RC series), then is always verified:

$C = \frac {I(t)} {\frac{d}{dt}(V_s(t)-R\;I(t))}$ for all t

Of course, when the denominator go to zero the numerator too.

But your current measurements has a slight asymmetry -> your model is not appropriate.
A C with a leakage resistance will be better.

Furthermore, you have a few points and made a numerical derivation ==> Giant errors.
Errors that have higher incidence precisely when the denominator approaches 0 ==> is always better integrate numerically derived.

Finally, if you find differences between the results of your procedure and the circuit theory, remember there are 99.99999% chance that you are wrong.

#### Osman Ceylan

##### Junior Member level 1 Thanks for the interting ideas. However we did not have an answer yet. I think I have enough data, I use MATLAB and resolution is smaller than 10^-24. I checked the numerical derivation, it is very OK.

I added my numerical solution. If we neclect R, and input voltage is sin(t), i(t) becomes cos(t). so it seems C value turns to tan(t) function. At first, I thought it is a kind of boundry value problem, but as you see there is no constant point at the drawing. So, I dont know which part is useful for me.
blue line is voltage, green line is current, red line is C value. all vaues are normalized. as you see, when derivation goes zero, capacitance goes infinite. Additionally, C is always changing... That is my problem, why C is always changing at the numerical analysis?

##### Super Moderator
Staff member Attachment 116440

Sorry, your attachment expired soon after you posted it. This is not your fault.

Can you add the image again, by clicking the 'Add an Image' button?

#### ferdem

##### Full Member level 2 If we neclect R, and input voltage is sin(t), i(t) becomes cos(t). so it seems C value turns to tan(t) function.
NO.
How is it tan(t)? It is still constant.
I guess I have found the bug! #### Ratch In a RC circuit, if the voltage source is a sinusoidal source, I found the given equation. C is constant.
I tried to solve this problem in time domain. So, I use a source in an EDA tool. I found the current in time. I know the voltage. I use simple numerical derivaton df(x)=[f(x2)-f(x1)]/(x2-x1). In this case, derivation is almost zero at the peak and bottom of the sinus. So, capacitance goes infinite. What am I doing wrong?
View attachment 115956

Since this is a circuit driven by a sinusoidal source, you can find out everything by using phasors. No derivatives are needed. What are you trying to find out, anyway? You don't say what it is.

Ratch

#### Osman Ceylan

##### Junior Member level 1 Ratch, I am looking for time domain numerical solution.

Guys, please do not try to change topic. I know phasor, I know differential equations, I know everything about the circuit theory. I do not know how to solve this problem in MATLAB in time domain. No hand-solution, no differential equation, no analysis on paper.

Is it clear enough?

Status
Not open for further replies.