Let's write down KVL in direction of current flow for an LC circuit. We have 2 cases:

a) $$\-\frac{q}{c} + L\frac{dI}{dt} = 0\$$, which is wrong.

b) $$\\frac{q}{c} + L\frac{dI}{dt} = 0\$$, which is the correct equation.

How can this be?

• I notice that in the diagrams, you've changed the sign of the current AND Esi between the two, however in your equations only one is inverted. I suggest therefore you explicitly spell out the conventions you're using for current and voltage a) so that we can better help you if you edit those into the question and b) in doing that you'll probably discover your error anyway. Commented Apr 15, 2023 at 18:16
• @Neil_UK I added the detailed view on self-inductance to a photo. It creates the EMF in the opposite direction to the current flow
– Sgg8
Commented Apr 15, 2023 at 18:42
• @Neil_UK I also didn't change the sine of $L\frac{dI}{dt}$ since in both cases $E_{si}$ is in the direction opposite to the current flow
– Sgg8
Commented Apr 15, 2023 at 18:50

The equations that you are concerned about are homogeneous. In other words zero-input. Yet you show a voltage source in series that somehow is to represent the voltage across the inductor. This may be an attempt to represent an initial condition, but it doesn't work. It certainly does not represent the inductor voltage.

Kirchhoff's voltage law is not influenced by current in the circuit. The currents in a particular branch may be directed opposite the KVL direction.

Both of the OP's figures a and b can be displayed (homogeneously)as in my Figures 1 and 2. The arrow in my figures indicate the direction taken when evaluating KVL (KVL direction).
It does not represent current.

L and C are in parallel so the polarity symbols are placed to indicate that. So it is easy to see that $$\v_C=v_L\$$.

But the question is about KVL. There are a couple of ways to walk the KVL path. The one that I prefer treats an element's voltage as positive if the positive terminal is encountered first before passing across the element. If the negative terminal is encountered first then the element's voltage is considered negative.

From Figure 1 below C is acting as a source: $$v_L-v_C=0\tag{Equation 1}$$.

From Figure 2 below L is acting as a source: $$v_C-v_L=0\tag{Equation 2}$$.

Either equation can be derived from the other by multiplying by $$\-1\$$

KVL works regardless of the underlying current, which can be completely unknown. The KVL part of the answer ends with equations 1 and 2. Going further, the choice of voltage formula is not based on a circuit current, but on the relationship between voltage and current that is established by the defining relation for the element. The defining relations for L and C as sources is the negative of their defining relations as passive elements. By inserting the appropriate defining relations into the KVL result, the solution to the differential equation will reveal the current unknown to KVL

The next step is to apply defining relations in the right way to obtain the form of the OP's equations.

A defining relation for a capacitor as a passive element (opposing the current) is: $$v_C=\frac{q}{C}$$ Use this in Equation 2.

But when the capacitor is a source (supporting the current): $$v_C=-\frac{q}{C}$$ because current is leaving its positive terminal.
Use this in Equation 1.

A defining relation for an inductor as a passive element (opposing the current) is: $$v_L=L\frac{di}{dt}$$ Use this in Equation 1.

But when the inductor is a source (supporting the current): $$v_L=-L\frac{di}{dt}$$ because current is leaving its positive terminal.
Use this in Equation 2.

Substituting the appropriate defining relations into Equations 1 and 2 produces the same correct result by both KVL paths:$$\frac{q}{C}+L\frac{di}{dt}=0$$

simulate this circuit – Schematic created using CircuitLab

• "Kirchhoff's voltage law is not influenced by current in the circuit" - yet you are choosing the voltage formula based on some current that is not even labeled in the circuit diagrams you provided. Explain this, please
– Sgg8
Commented Apr 16, 2023 at 8:59
• KVL works regardless of the underlying current, which can be completely unknown. The KVL part of the answer ends with equations 1 and 2. Going further, the choice of voltage formula is not based on a circuit current, but on the relationship between voltage and current that is established by the defining relation for the element. The defining relations for L and C as sources is the negative of their defining relations as passive elements. By inserting the appropriate defining relations into the KVL result, the solution to the differential equation will reveal the current unknown to KVL. Commented Apr 16, 2023 at 12:54
• For me KVL is simply $\varphi_A - \varphi_B + (\varphi_B - \varphi_A) = U_C + U_L = 0$, where $A$ and $B$ are points on positive and negative plate of the capacitor respectively. The capacitance is defined in terms of potential positive plate minus negative plate. This gives me a way of relating voltage to charge in KVL. How do you define voltages in terms of potential of each terminal and how do you determine the polarity of each terminal of each circuit element?
– Sgg8
Commented Apr 16, 2023 at 14:47

For the capacitor

$$v_A - v_B = \frac{1}{C} \int{i}dt$$

You have changed the sign of q, but the sign of q must be the same as the sign of I since

$$q(t) = \int{i(t)}dt$$

Assigning a positive and negative charge to the plates of the capacitor isn't too useful since the charge will change over time depending on the current

• Current direction will also change. And also the current direction can be chosen however one wants and it shouldn't lead to any contradictions when I write down the KVL. Also, capacitance is defined as $C = \frac{q}{V}$ where $V = V_+ - V_-$; $V_+$ and $V_-$ are potential on positively and negatively charged conductor respectively (see, for example, Griffiths 2.5.4, eq. 2.53). Thus there is no ambiguity in doing what I did
– Sgg8
Commented Apr 15, 2023 at 20:39
• Which plate of the capacitor is positively and negatively charged is irrelevant for KVL and is why you are getting the wrong answer in a). KVL is a statement about the potential difference across both elements. The potential difference is a function of current over time (charge is just another function of current). Therefore both statements a) and b) cannot both be true, because this would require that $$i(t) = -i(t)$$ which can't be true if current is flowing. As @Neil_UK has said you will have to clearly state your current and voltage conventions to understand the error Commented Apr 15, 2023 at 23:02
• How can I write down KVL in terms of capacitor voltage $U_C$ and then transform it into an equation in terms of $q$ if I need the relation $C=\frac{q}{V}$ for this. And I need to know which plate is charged positively to relate $V$ to $U_C$(they are the same magnitude, but could be the opposite sign)
– Sgg8
Commented Apr 15, 2023 at 23:05
• You are thinking statically, when this is a dynamical system. If you ignore the instantaneous charge on the plates for a moment and you just set a convention for current direction and direction of the KVL loop, you can then go about writing down a differential equation: $$\frac{1}{C} \int{i(t)} dt + L \frac{di(t)}{dt} = 0$$ Commented Apr 15, 2023 at 23:32
• Once you have done this, you can solve it, and the Initial conditions will incorporate the information you have about which plate starts out positively charged and the amount of charge on the plates at any particular time. Everything will fall out of that differential equation if you follow the sign convention through Commented Apr 15, 2023 at 23:32