Skip to content

symcool/EM-Simulator

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

#EM Simulator

EM Simulator is a 3D simulation and visualization software written in C# and XNA for electric (and soon, magnetic) fields. The simulator allows you to place point charges in a 3D world and view the resulting vector field and field lines.

##System Requirements

EM Simulator uses XNA, and thus has specific system requirements:

  1. Windows XP or newer
  2. DirectX 9 or newer compatible graphics card (Intel integrated graphics may suffice - not tested)

In the future I plan to either rewrite EM Simulator in OpenGL or utilize Mono to achieve greater platform compatibility.

##Quick Setup Express setup:

  1. Download the latest build under releases.
  2. Unzip, and run setup.exe.
  3. The installer will automatically install the .NET Framework 4 and XNA, if necessary.
  4. The installer will then automatically start EM Simulator.
  5. Read below for a brief introduction of how to use.
  6. Enjoy!

##Getting started ###Controls

W, A, S, D, Mouse
Move and rotate the camera in space
Esc
Exit EM Simulator
Tab
Open EM Simulator console (see below)
F11
Toggle Fullscreen
F12
Take Screenshot
Ctrl
Free mouse

###Console The EM Simulator console is the primary way to interact with the world: you use it to add charges, toggle vectors and field lines on or off, delete charges, etc.

The console uses Python, specificaly IronPython as an interpreter.

Math Conventions: EM Simulator uses a left-handed, Y up coordinate system.

Open the console by pressing tab.

####Examples To get familiar with the console in EM Simulator, run these examples sequentially. Use the mouse and keyboard controlls to fully interact with EM Simulator, to get the best view of the charges and electric field in the world.

Electric dipole setup

addCharge(-10,0,0,-0.2)
addCharge(10,0,0,0.2)

Now view field lines instead of vectors

toggleLines()
toggleVectors()

Dipole Screenshot

Add a third charge

addCharge(-5,20,25,0.4)

Now view the vector field rather than the field lines

toggleVectors()
toggleLines()

Vector Field Screenshot

##Console Command Documentation Please refer to the wiki page for documentaion and a full list of all available console commands.

##Scripting Documentation The EM Simulator console uses Python as interpreter. Thus, it can elegantly load and execute Python scripts, automating commands in the console. To see a quick demo of script execution in action, simply type run("capacitor") in the console, and after a few seconds it will generatea parallel plate capacitor.

To make your own Python scripts, write Python code as you normally would, and then make the same Python function calls as you do in the console. For example, consider the follow Python code, which generates a row of point charges:

for x in range(0, 10):
    addCharge(x,0,0,0.05)

Then, run the command openContentDir() which will open the Content directory in Windows Explorer. Place your Python files in the Content directory! They should then be recognized if you run lsScripts()

About

3D Electromagnetic field simulator written in C# with XNA

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 99.5%
  • C# 0.5%