My phys 291 project has been to make a C++ program which investigates a RLC-circuit. The program gives you values for a known circuit in resonans and five random circuits in resonans, and gives six plots were the voltage are plotet as a function of frequency. The plots have a peak wich is the maximum voltage over the resistance (wich is when the circuit is in resonans) and values for C,L,R and expected resonans frequency. You can control how many plots you want. The only thing you have to do is to change the value for M to how many random plots you want.
RLC.cpp is the main file. You have to load it and execute it in ROOT as the codes does not have a main() function.
I have used some prototypes in this program to make my life easyer. it's char * MixStringInt(string name,float num) wich is a method that combines a string and a float numer. This I use in the ROOT commands to make my labels that gives the values for R,L,C and expected resonans frequency. The other is void CalculateVoltage (int N,float Res, float L, float C, float Vinn, float * w, float * Varr) wich is a Method that calculates an entire voltage array based on the quantities C,L,Res,Vinn. N is the number of discrete points, w is a pointer to the frequency array. Varr is a pointer to the output array. NOTE: This function does not return the array but uses a buffer. The last prototype is void FillRandom(int N,int spr,float scaling,float * array). Wich is used in combination with srand((unsigned)time(0)) to fill in arrays with randomgenerators for R,L,C and V.
Here are some of the plots you can get.
Plot 1 shows a known circuit.Good circuit
And rest of the plots shows random circuits.Random circuit 1
Random circuit 2
Random circuit 3
On my computer the name of the labels is a bit strange, but if you use a linux computer you should get normal letters and integers.
A special thanks to Boris Wagner for all his help during the semester.