Skip to content

Commit

Permalink
Merge branch 'master' of github.com:ManuelLerchner/MolSim-WS23-24
Browse files Browse the repository at this point in the history
  • Loading branch information
ManuelLerchner committed Dec 15, 2023
2 parents 5d07e33 + cbad160 commit 4e404f2
Show file tree
Hide file tree
Showing 18 changed files with 159 additions and 458 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ In this section we describe how to build the project. You can use the following

- An example run could look like this: `./MolSim ../../body_collision.cub -d 0.0002 -e 5`

- Further information about the ossible input file formats can be found in the `/docs` directory.
- Further information about the possible input file formats can be found in the `/docs` directory.

- **Note:** Some input file formats can provide own simulation parameters. In the case that the user provides additional parameters via the command line, both sources of parameters are merged. If a conflict occurs, the command line parameters take precedence, since it was explicitly requested by the user.
- **Note:** Input files can, and for some cases have to provide own simulation parameters. In case the user provides additional parameters via the command line, both sources of parameters are merged. If a conflict occurs, the command line parameters take precedence, since it was explicitly requested by the user. To avoid mixups, it is recommended to define all parameters in the input file and only use command line for small, temporary adjustments to avoid changing the input file.

### Run the tests

Expand Down
71 changes: 3 additions & 68 deletions docs/InputFileFormats.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,77 +7,12 @@
Our program supports multiple file formats as input files, which are interpreted differently. The file format is automatically determined by the file extension.
The following file extensions are supported:

- `.ps`: Contains Raw Particle Data
- `.cub`: Contains arguments for the internal cuboid generator
- `.xml`: Contains data for particle generation and allows to specify all the input parameters for the simulation as well

In the following sections, the file formats are explained in detail.

## File Formats Explained

### .ps

The `.ps` file format contains raw particle data. It is used to directly specify the initial state of the simulation.

- Starts with an arbitrary amount of comment lines, which start with `#` and are only allowed at the beginning of the file
- The first non-comment line contains a single integer, the number of particles in the simulation
- Now follow an amount of lines equal to the number of particles, each containing the following arguments (each seperated by spaces):
- The particle's position in 3D space (Three floating point numbers, seperated by spaces)
- The particle's initial velocity (Three floating point numbers, seperated by spaces)
- The particle's mass (A single floating point number the particle's mass)

Note: Floating point numbers can be written in scientific notation, e.g. `1.0e-3` for `0.001`.

An example file could look like this:

```text
# This is a comment
# xyz-coord velocity mass
4
0.0 0.0 0.0 0.0 0.0 0.0 1.0
0.0 1.0 0.0 -1.0 0.0 0.0 3.0e-6
0.0 5.36 0.0 -0.425 0.0 0.0 9.55e-4
34.75 0.0 0.0 0.0 0.0296 0.0 1.0e-14
```

### .cub

The `.cub` file format contains arguments for the internal cuboid generator. The program uses these arguments to generate one or multiple cuboids of particles given the specified parameters.

- Consists of one or more definitions of cuboids with the following arguments (each on a seperate line), where the values on each line are seperated by spaces:
- The coordinate of the lower left front-side corner: '`double` `double` `double`'
- Grid Dimensions: '`int` `int` `int`'
- Distance of the particles (mesh width): '`double`'
- Mass of a single particle: '`double`'
- Initial velocity of the particles: '`double` `double` `double`'
- Initial temperature of the particles (for temperature dependent wobbling, excludes temperature created by full cuboid velocity) '`double`'
- Type of the cuboid: '`int` used for labeling particles in the cuboid'
- Outside the cuboid definitions an arbitrary amount of comment lines, which start with `#` and empty lines are allowed, furthermore comments are allowed at the end of a line after the last argument

Note: Floating point numbers can be written in scientific notation, e.g. `1.0e-3` for `0.001`.

An example file could look like this:

```text
# Definition of Cuboid 1
0.0 0.0 0.0 # Lower left front-side corner
10 10 10 # Grid Dimensions
0.1 # Distance of the particles (mesh width)
1.0 # Mass of a single particle
0.4 0.0 0.0 # Initial velocity of the particles
0.0 # Initial temperature
0 # Type of the cuboid
# Definition of Cuboid 2
10.0 10.0 10.0 # Lower left front-side corner
10 10 10 # Grid Dimensions
0.1 # Distance of the particles (mesh width)
1.0 # Mass of a single particle
0.0 0.4 0.0 # Initial velocity of the particles
0.0 # Initial temperature
1 # Type of the cuboid
```

### .xml

The `.xml` file format can be used to specify all the input parameters for the simulation at once. Therefore, it is preferred over the other file formats.
Expand All @@ -92,9 +27,9 @@ Its definition is based on the [simulation_schema.xsd](simulation_schema.xsd) fi
- `<particle_container>` Which particle container implementation should be used

- Particle Data:
- `<cuboid_spawner>`: Input data for a cuboid spawner, which generates particles in a cuboid shape
- `<sphere_spawner>`: Input data for a sphere spawner, which generates particles in a spherical shape
- `<individual_particle>`: Input data for a single particle, which is placed at the specified position
- `<cuboid_spawner>`: Input data for a cuboid spawner, which generates particles in a cuboid shape (2 or 3 dimensional)
- `<sphere_spawner>`: Input data for a sphere spawner, which generates particles in a spherical shape (2 or 3 dimensional)
- `<single_particle_spawner>`: Input data for a single particle, which is placed at the specified position

An example file could look like this:

Expand Down
17 changes: 0 additions & 17 deletions input/body_collision/body_collision_assignment2.cub

This file was deleted.

73 changes: 73 additions & 0 deletions input/body_collision/body_collision_assignment2.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?xml version="1.0"?>
<!-- just a sanity check: body collision rewritten to xml -->
<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../simulation_schema.xsd">

<settings>
<fps>24</fps>
<video_length>30</video_length>
<delta_t>0.0002</delta_t>
<end_time>5.0</end_time>
<third_dimension>false</third_dimension>
<particle_container>
<directsum_container />
</particle_container>
<forces>
<LennardJones />
</forces>
<output_format>vtu</output_format>
</settings>


<particle_source>
<cuboid_spawner>
<lower_left_front_corner>
<x>0.0</x>
<y>0.0</y>
<z>0.0</z>
</lower_left_front_corner>
<grid_dim>
<x>40</x>
<y>8</y>
<z>1</z>
</grid_dim>
<grid_spacing>1.1225</grid_spacing>
<temperature>0.1</temperature>
<mass>1</mass>
<velocity>
<x>0.0</x>
<y>0.0</y>
<z>0.0</z>
</velocity>
<type>0</type>
<epsilon>5.0</epsilon>
<sigma>1.0</sigma>
</cuboid_spawner>

<cuboid_spawner>
<lower_left_front_corner>
<x>15.0</x>
<y>15.0</y>
<z>0.0</z>
</lower_left_front_corner>
<grid_dim>
<x>8</x>
<y>8</y>
<z>1</z>
</grid_dim>
<grid_spacing>1.1225</grid_spacing>
<temperature>0.1</temperature>
<mass>1</mass>
<velocity>
<x>0.0</x>
<y>-10.0</y>
<z>0.0</z>
</velocity>
<type>1</type>
<epsilon>5.0</epsilon>
<sigma>1.0</sigma>
</cuboid_spawner>

</particle_source>

</configuration>
Binary file removed input/periodic_system/eingabe-figure-8.ps
Binary file not shown.
78 changes: 78 additions & 0 deletions input/periodic_system/eingabe-figure-8.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?xml version="1.0"?>
<!-- just a sanity check: body collision rewritten to xml -->
<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../simulation_schema.xsd">

<settings>
<fps>24</fps>
<video_length>30</video_length>
<delta_t>0.0005</delta_t>
<end_time>20.0</end_time>
<third_dimension>false</third_dimension>
<particle_container>
<directsum_container />
</particle_container>
<forces>
<Gravitational />
</forces>
<output_format>vtu</output_format>
</settings>


<particle_source>
<single_particle_spawner>
<position>
<x>-1.0</x>
<y>0.0 </y>
<z>0.0</z>
</position>
<temperature>0</temperature>
<mass>1</mass>
<velocity>
<x>0.347113</x>
<y>0.532727</y>
<z>0.0</z>
</velocity>
<type>0</type>
<epsilon>1.0</epsilon>
<sigma>1.2</sigma>
</single_particle_spawner>

<single_particle_spawner>
<position>
<x>1.0</x>
<y>0.0 </y>
<z>0.0</z>
</position>
<temperature>0</temperature>
<mass>1</mass>
<velocity>
<x>0.347113</x>
<y>0.532727</y>
<z>0.0</z>
</velocity>
<type>1</type>
<epsilon>1.0</epsilon>
<sigma>1.2</sigma>
</single_particle_spawner>

<single_particle_spawner>
<position>
<x>0.0</x>
<y>0.0 </y>
<z>0.0</z>
</position>
<temperature>0</temperature>
<mass>1</mass>
<velocity>
<x>-0.694226</x>
<y>-1.065454</y>
<z>0.0</z>
</velocity>
<type>2</type>
<epsilon>1.0</epsilon>
<sigma>1.2</sigma>
</single_particle_spawner>
</particle_source>

</configuration>
6 changes: 1 addition & 5 deletions src/io/input/FileInputHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,7 @@ std::tuple<std::vector<Particle>, std::optional<SimulationParams>> FileInputHand

std::unique_ptr<FileReader> file_reader;

if (file_extension == ".ps") {
file_reader = std::make_unique<PsFileReader>();
} else if (file_extension == ".cub") {
file_reader = std::make_unique<CubFileReader>();
} else if (file_extension == ".xml") {
if (file_extension == ".xml") {
file_reader = std::make_unique<XMLFileReader>(fresh, allow_recursion);
} else if (file_extension == ".chkpt") {
file_reader = std::make_unique<ChkptPointFileReader>();
Expand Down
2 changes: 0 additions & 2 deletions src/io/input/FileInputHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

#include "io/input/InputFormats.h"
#include "io/input/chkpt/ChkptPointFileReader.h"
#include "io/input/custom_formats/cub/CubFileReader.h"
#include "io/input/custom_formats/ps/PsFileReader.h"
#include "io/input/xml/XMLFileReader.h"
#include "simulation/SimulationParams.h"

Expand Down
2 changes: 1 addition & 1 deletion src/io/input/InputFormats.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#include "InputFormats.h"

const std::set<std::string> get_supported_input_file_extensions() { return {".ps", ".cub", ".xml", ".chkpt"}; }
const std::set<std::string> get_supported_input_file_extensions() { return {".xml", ".chkpt"}; }
31 changes: 0 additions & 31 deletions src/io/input/custom_formats/FileLineReader.cpp

This file was deleted.

Loading

0 comments on commit 4e404f2

Please sign in to comment.