Simple file format for import and export

7 views
Skip to first unread message

Andreas Ipp

unread,
May 19, 2012, 6:51:09 PM5/19/12
to open...@googlegroups.com
As more and more feature get added, we should think about a suitable file format for loading and saving simulation states. A new student will work on this, but it is good if we define the file format first. I'm thinking of a variation of the Windows INI file format ( http://en.wikipedia.org/wiki/INI_file ) because of its simplicity. (Maybe Jan would like to convince us that XML would be better, but I think that would be overkill for our purposes. Scientists only know how to edit simple text files :-) )

Here is a suggested file format.

------------------
# OpenPixi file format. 
# Comments start with '#' and are allowed anywhere.
[Simulation]
version=0.4  # version number is always good to know
width=100
height=100
timestep=0.01
solver=BorisRelativistic
grid=YeeGrid
boundary=PeriodicBoundary

[ConstantForceRelativistic]
bx=1 # add some background magnetic field.
# other values are 0 by default.

[Particle] # add a particle
p=20,25  # position
v=0,0  # initial velocity
radius=1
mass=0.1
charge=+1

[Particle]  # create a second particle
p=70,25
v=-5,0 # let it collide with first particle
# if parameters like mass or charge are omitted,
# then parameters from previous particle are used.
-----

Instead of specifying each particle separately, one could also create many random particles at once:

--------------------
[RandomParticles]
n=1000 # number of particles
vmax = 2 # maximum velocity, randomly distributed
radius=0.23
mass=0.1
charge=+1

[RandomParticles]
n=500 # create 500 more particles
charge=-1 # with opposite charge.
--------------------

Additionally, simulation data could be written to a file:

----------------
[Output]
filename=C:\mydata\two-particle-collision1.dat
data=time, p.1.x, p.1.y  # three columns: time, particle1.x, particle2.x

[Output]
# Let's write at the same time the data for particle 2 into another file
filename=C:\mydata\two-particle-collision2.dat
data=time, p.2.x, p.2.y
-------------

What do you think?

Jan Kis

unread,
May 19, 2012, 8:05:43 PM5/19/12
to open...@googlegroups.com
I do not really get what for is the section [output] in your example doing but maybe it is not important.

It might be also useful to have a section for referencing further files with simulation data. Then one can have a single file with some testing particles which one can use in several different simulation setups. 
[ref]
file=C:\...

Maybe Jan would like to convince us that XML would be better
Actually, I think it would be less readable and too verbose for our purpose.

This link might be useful later on so that the person implementing this does not have to create its own parser for ini files:
http://stackoverflow.com/questions/190629/what-is-the-easiest-way-to-parse-an-ini-file-in-java
Reply all
Reply to author
Forward
0 new messages