Circuit Simulator

Prog

Not a Meme™
Staff member
Our final project in AP Physics C is to build a software simulation of some unit with which a student could do labwork. Most students with with standard kinematics or orbital mechanics, but I prefer the Electricity & Magnetism topics* because that's the kind of work I want to go into. So, in tradition of me doing absolutely no work all year and then asserting my genius by making a kickass final project, I opted to make a robust (for Physics C) electrical circuit simulator that can measure potentials and current over time and such. There are gaps in the circuit that can be filled with wire or resistors/capacitors/inductors (given as simple ohm/farad/henry values or complex attributes like resistivity or wire loops). I'll explain better tomorrow when I copypasta the writeup that's on my teacher's samba server.
*Except field theory, that's a load of bollocks

Unfortunately, I am restricted to using Easy Java Simulations, a buggy Java wrapper, despite the fact that this would probably be moderately easier in something like Visual C++, with a bit less hand holding and limitation. I've found that, even when using functions as they are intended to be used in EJS, they simply don't work right. Thankfully, I've been good with workarounds thus far.
Right now I only have screen photos to demonstrate my progress for a number of reasons, but expect more in-depth updates as time goes on.
EqkPM84h.jpg

YfI9ez6h.jpg

Did I mention that this is my first legit software project beyond Hello World or basic arithmetic?
(The code in which emf is changed is part of debugging, btw, and added by my teacher to verify that EJS was the one *Can'tSayThisOnTV*ing up. I just realized I haven't removed it yet.)
 
Is this a typical thing in AP Physics C? I'm going into the class next year and I've not heard of students having to develop software. Anyway, it seems interesting and probably useful for lots of real applications.
 
Is this a typical thing in AP Physics C? I'm going into the class next year and I've not heard of students having to develop software. Anyway, it seems interesting and probably useful for lots of real applications.
Probably not, this is an end-of-year project for my teacher specifically. He expected most students to do kinematic simulations (launch a ball and watch it fall, or watch planetary objects orbit) and, according to him, this is a whole lot more than he intended us to do.
Hey Prog,

Just saw the post on your Circuit Sim, and while my C coding sucks, you'd have a lot less of it to type there using a case/break deal instead of all of those if/else if. They really do the same thing, one of the nice things about coding, there's always more than one way to skin the cat, unless you're trying to squeeze every bit of speed from the code or save memory. The case/break is just cleaner IMO versus a mess of if/else if, which I used to do when I started coding also, so it's not a bad thing. ;)

Not sure if the syntax for your compiler is the same there, I code in mikroC here, but a case/break for what I can make out in the second screenshot there would look like this..

Code:
public String getComponentType(int propTest){

  switch(PropTest){

  case 0: return "gap"; break;
  case 1: return "wire"; break;
  case 2: return "resistor (simple)"; break;
  case 3: return "resistor (complex)"; break;
  case 4: return "capacitor (simple)"; break;
  case 5: return "capacitor (complex)"; break;
  //etc;
  //etc;

  }
}
Thank you @RDC, I have a very limited programming background and this was immensely helpful!
In that specific instance, I omitted break statements, because the parser makes a very hard stop at the return statement.
I meant to get an alpha for you guys but I keep getting an external exception from some code that I recently added that switches between amps and milliamps.
Pics, now that I have a copy on my home computer:
ZNu7VK7.png

pCDZu06.png

EMT5ECw.png

HhbYfmj.png

T3Fm5E3.png

wErvdrs.png

wErvdrs.png
 
Back
Top