Node voltage analysis – an example

Continuing with the method for node voltage analysis of circuits with current sources.

Consider the following circuit :

circuit

Stating the KCL (Kirchoffs current law) at each of the four nodes gives us the following system of equations :

equation

That we can solve for the three voltages va, vb and vc, knowing that vd = 0 and given the values for i1 and i7 and the resistances.

Node voltage analysis of a circuit

In this post I will talk about a method for finding node voltages in a specific general type of resistive circuit. Consider the circuit in the following diagram :

circuit

To find the node voltage at node a we take node b as the reference node. According to the KCL (Kirchoff’s current law) we have at node a :

equation_1

then,

equation_2

, because the voltage at point b is zero (its the reference point), we have :

equation_3 or equation_4

 

We will see in future posts how this analysis can be generalised to these types of circuits (resistive with current sources).

Kirchoff’s voltage and current laws

Gustav Robert Kirchoff, a professor at the University of Berlin, stated two laws that relate the current and the voltage in a circuit with two or more resistors.

Kirchoff’s current law states that the algebraic sum of the currents into a node at any instant is zero. We can illustrate this with the following diagram of a circuit node :

KCL

 

i1 -i2 + i3 – i4 = 0, meaning that the sum of currents entering a node is equal to the sum of the currents leaving the node.

Kirchoff’s voltage law states that the algebraic sum of all the voltages in a closed path is zero at all times. Take for example the following circuit :

KVL

 

vc -va-vb = 0 (note the polarity on each element of the circuit)

These rules are very useful in circuit analysis. It allows the setup of a system of equations that can be solved for obtaining voltages at each element and currents on each branch of the circuit.

Using log4jdbc on weblogic server 10.3

I am having a problem on a specific EJB container managed transaction. It fails to update a database row on some occasions. So I need to have a look at what is being sent  the database and check for any errors. Since I am connecting to an Oracle database, I am aware that logging through the oracle JDBC driver does not show me variable bindings on prepared statements. So I need to use another way to see what’s happening, and that’s when log4jdbc comes in.

EDIT : currently log4jdbc does not support XA. Only found this out at the end of the process.

Log4jdbc sits between the application and the real driver and gives us the chance to log JDBC calls with fine detail. In this post I will be logging just SQL statements.

First, get the libraries. We need the log4jdbc jar and the jars from the SLF4J project for abstracting away the concrete logging framework, which in this case is log4j.

So put the following jars :

  • log4jdbc4-1.2.jar
  • slf4j-log4j12-1.7.6.jar
  • slf4j-api-1.7.6.jar

in a directory (here named $LOGGING_HOME), and find the weblogic script named commEnv.sh, which should be in the directory $BEA_HOME/wlserver_10.3/common/bin.

In this file you should place the three jars in the $LOGGING_HOME directory in the beginning of the classpath defined by the WEBLOGIC_CLASSPATH variable.

Then run the WLST command line tool to update your connection pool information. Execute the following commands replacing the shell variables with the values specific for your environment :

> readDomain('$DOMAIN_HOME') ;

find the path to the descriptor with your datasource’s connection pool configuration. In this case the datasource is named ‘portalPoolDataSource’ :

> cd('/JDBCSystemResource/portalPoolDataSource/JdbcResource');
> cd('portalPoolDataSource/JDBCDriverParams/NO_NAME_0');

If you then do an ls() you will see the configuration of the connection pool.

We want to change the properties named ‘DriverName’ and  ‘URL’:

> set('DriverName', 'net.sf.log4jdbc.DriverSpy');
> set('URL', 'jdbc:log4jdbc:oracle:thin:@localhost:1521:xe');

As per the log4jdbc documentation the new database URL is equal to the old one, but putting the string ‘:log4jdbc:’ between the leading ‘jdbc’ and the ‘oracle’ substrings.

Then write the configuration to disk :

> setOption('OverwriteDomain', 'true');
> updateDomain();

, and exit the WLST tool. Now we need to configure logging. I already had a log4j configuration file in xml format called log4j.xml. In my startup procedure I am using the WLST tool to start the AdminServer, and pass system properties to the startServer command. To indicate where the log configuration is located one may define the system property :

-Dlog4j.configuration=file://$DOMAIN_HOME/log4j.xml

In my case this setting was always ignored. The config file considered by weblogic was one found inside one of its jars. It was looking for the first file in the classpath with the path described in the following line extracted from the startup log :

log4j: Trying to find [resources/comdev/default-log4j.properties] using context classloader weblogic.utils.classloaders.GenericClassLoader@1dea651

This output was logged only when the system property ‘-Dlog4j.debug’ is passed on server startup.

I then proceeded to convert my log4j.xml into properties format and placing it first on the classpath, so that It could be found before any other file with a similar relative path.

In the logging configuration file I defined the log level for the jdbc.sqlonly category :

log4j.category.jdbc.sqlonly=INFO, FILE

That was it. the SQL is now being logged on the appender named FILE.

Integration of the power flowing through an element

I am currently learning about electric circuits and came across some math procedures that I have not used in a long time. Such as integrating a exponential function of the eulers number.

Take an electric element that is subjected to a current and therefore a voltage between its terminals.
We know that :

  • the voltage across its terminals is a function of time, v=2e-t
  • the current flowing through it is also a function of time, i=3e-t

We want to know the amount of electrical charge goes into to element in a time period from 0 to 10 seconds. We know that power is the time rate of change of the charge :

equation_1

Then the charge can be found by integrating the power in a time period:

equation_2

Substituting the power by its constituents, voltage and current we get :

equation_3

To integrate the function of t define u as a function of t :

(1)equation_4

Substituting the function in the integral yields :

(2)equation_5

Then, by derivating both sides of the equation (1) we get :

Substituting into the equation (2) :

equation_7

Then, to calculate the amount of charge between instants 0 and 10 just :

equation_8