tsmall fixes - sphere - GPU-based 3D discrete element method algorithm with opt… | |
git clone git://src.adamsgaard.dk/sphere | |
Log | |
Files | |
Refs | |
LICENSE | |
--- | |
commit 5dbc0a8544a6dfa40505639271fb7ca1a1834be5 | |
parent 63cf7ba3c83aac1a3f2b7836262fbc7b9052b84f | |
Author: Anders Damsgaard <[email protected]> | |
Date: Sun, 17 Mar 2013 21:22:39 +0100 | |
small fixes | |
Diffstat: | |
M INSTALL.sh | 2 +- | |
M doc/html/_sources/introduction.txt | 16 ++++++++++------ | |
M doc/html/genindex.html | 4 ++++ | |
M doc/html/introduction.html | 30 ++++++++++++++++++++++-------- | |
M doc/html/objects.inv | 0 | |
M doc/html/python_api.html | 10 ++++++++-- | |
M doc/html/searchindex.js | 4 ++-- | |
M doc/pdf/sphere.pdf | 0 | |
M doc/sphinx/conf.py | 8 ++++---- | |
M doc/sphinx/introduction.rst | 16 ++++++++++------ | |
D python/bondtest.py | 44 -----------------------------… | |
M python/shear-test.py | 12 ++++++------ | |
M src/sphere.cpp | 13 ++++++++----- | |
D tests/tests.py | 114 -----------------------------… | |
14 files changed, 75 insertions(+), 198 deletions(-) | |
--- | |
diff --git a/INSTALL.sh b/INSTALL.sh | |
t@@ -1,2 +1,2 @@ | |
-export NVSDKCOMPUTE_ROOT=/home/adc/NVIDIA_GPU_Computing_SDK | |
+export NVSDKCOMPUTE_ROOT=/home/adc/NVIDIA_CUDA-5.0_Samples | |
cmake . && make | |
diff --git a/doc/html/_sources/introduction.txt b/doc/html/_sources/introductio… | |
t@@ -14,6 +14,7 @@ Requirements | |
The build requirements are: | |
* A Nvidia CUDA-supported version of Linux or Mac OS X (see the `CUDA toolki… | |
* `GNU Make <https://www.gnu.org/software/make/>`_ | |
+ * `CMake <http://www.cmake.org>`_ | |
* The `GNU Compiler Collection <http://gcc.gnu.org/>`_ (GCC) | |
* The `Nvidia CUDA toolkit and SDK <https://developer.nvidia.com/cuda-downlo… | |
t@@ -42,18 +43,21 @@ Optional tools, required for building the documentation: | |
Building *sphere* | |
----------------- | |
-All instructions required for building *sphere* are provided in a number of ``… | |
+All instructions required for building *sphere* are provided in a number of ``… | |
- $ cd src | |
- $ make | |
+ $ cmake . && make | |
-If successfull, the GNU Makefile will create the required data folders, object… | |
+If successfull, the Makefiles will create the required data folders, object fi… | |
- $ ./sphere_* --version | |
+ $ ./sphere --version | |
The output should look similar to this: | |
-.. program-output:: ../../sphere_linux_X86_64 --version | |
+.. program-output:: ../../sphere --version | |
+ | |
+The build can be verified by running a number of automated tests:: | |
+ | |
+ $ make test | |
The documentation can be read in the `reStructuredText <http://docutils.source… | |
diff --git a/doc/html/genindex.html b/doc/html/genindex.html | |
t@@ -100,6 +100,10 @@ | |
<table style="width: 100%" class="indextable genindextable"><tr> | |
<td style="width: 33%" valign="top"><dl> | |
+ <dt><a href="python_api.html#sphere.cleanup">cleanup() (in module sphere)</a> | |
+ </dt> | |
+ | |
+ | |
<dt><a href="python_api.html#sphere.Spherebin.consolidate">consolidate() (sp… | |
</dt> | |
diff --git a/doc/html/introduction.html b/doc/html/introduction.html | |
t@@ -72,6 +72,7 @@ The ultimate aim of the <em>sphere</em> software is to simul… | |
<dd><ul class="first last simple"> | |
<li>A Nvidia CUDA-supported version of Linux or Mac OS X (see the <a class="re… | |
<li><a class="reference external" href="https://www.gnu.org/software/make/">GN… | |
+<li><a class="reference external" href="http://www.cmake.org">CMake</a></li> | |
<li>The <a class="reference external" href="http://gcc.gnu.org/">GNU Compiler … | |
<li>The <a class="reference external" href="https://developer.nvidia.com/cuda-… | |
</ul> | |
t@@ -107,17 +108,30 @@ The ultimate aim of the <em>sphere</em> software is to s… | |
</div> | |
<div class="section" id="building-sphere"> | |
<h2>Building <em>sphere</em><a class="headerlink" href="#building-sphere" titl… | |
-<p>All instructions required for building <em>sphere</em> are provided in a nu… | |
-<div class="highlight-python"><pre>$ cd src | |
-$ make</pre> | |
+<p>All instructions required for building <em>sphere</em> are provided in a nu… | |
+<div class="highlight-python"><pre>$ cmake . && make</pre> | |
</div> | |
-<p>If successfull, the GNU Makefile will create the required data folders, obj… | |
-<div class="highlight-python"><pre>$ ./sphere_* --version</pre> | |
+<p>If successfull, the Makefiles will create the required data folders, object… | |
+<div class="highlight-python"><pre>$ ./sphere --version</pre> | |
</div> | |
<p>The output should look similar to this:</p> | |
-<div class="system-message"> | |
-<p class="system-message-title">System Message: ERROR/3 (<tt class="docutils">… | |
-Command u’../../sphere_linux_X86_64 –version’ failed: [Errno… | |
+<div class="highlight-text"><div class="highlight"><pre>.---------------------… | |
+| _ Compiled for 3D | | |
+| | | | | |
+| ___ _ __ | |__ ___ _ __ ___ | | |
+| / __| '_ \| '_ \ / _ \ '__/ _ \ | | |
+| \__ \ |_) | | | | __/ | | __/ | | |
+| |___/ .__/|_| |_|\___|_| \___| | | |
+| | | | | |
+| |_| Version: 0.35 | | |
+`-------------------------------------´ | |
+ A discrete element method particle dynamics simulator. | |
+ Written by Anders Damsgaard Christensen, license GPLv3+. | |
+</pre></div> | |
+</div> | |
+<p>The build can be verified by running a number of automated tests:</p> | |
+<div class="highlight-python"><pre>$ make test</pre> | |
+</div> | |
<p>The documentation can be read in the <a class="reference external" href="ht… | |
<div class="highlight-python"><pre>$ cd doc/sphinx | |
$ make html | |
diff --git a/doc/html/objects.inv b/doc/html/objects.inv | |
Binary files differ. | |
diff --git a/doc/html/python_api.html b/doc/html/python_api.html | |
t@@ -179,7 +179,7 @@ Returns porosity values and depth</p> | |
<dl class="method"> | |
<dt id="sphere.Spherebin.run"> | |
-<tt class="descname">run</tt><big>(</big><em>verbose=True</em>, <em>hideinputf… | |
+<tt class="descname">run</tt><big>(</big><em>verbose=True</em>, <em>hideinputf… | |
<dd><p>Execute sphere with target project</p> | |
</dd></dl> | |
t@@ -206,7 +206,7 @@ initial height per second.</p> | |
<dl class="method"> | |
<dt id="sphere.Spherebin.thinsection_x1x3"> | |
-<tt class="descname">thinsection_x1x3</tt><big>(</big><em>x2='center'</em>, <e… | |
+<tt class="descname">thinsection_x1x3</tt><big>(</big><em>x2='center'</em>, <e… | |
<dd><p>Produce a 2D image of particles on a x1,x3 plane, intersecting the seco… | |
Output is saved as ‘<sid>-ts-x1x3.txt’ in the current folder… | |
<p>An upper limit to the pressure color bar range can be set by the cbmax para… | |
t@@ -258,6 +258,12 @@ velocity in m/s, default value is -0.001 m/s (i.e. downwa… | |
</dd></dl> | |
<dl class="function"> | |
+<dt id="sphere.cleanup"> | |
+<tt class="descclassname">sphere.</tt><tt class="descname">cleanup</tt><big>(<… | |
+<dd><p>Remove input/output files and images from simulation</p> | |
+</dd></dl> | |
+ | |
+<dl class="function"> | |
<dt id="sphere.convert"> | |
<tt class="descclassname">sphere.</tt><tt class="descname">convert</tt><big>(<… | |
<dd><p>Converts all PPM images in img_out to graphicsformat, using ImageMagick… | |
diff --git a/doc/html/searchindex.js b/doc/html/searchindex.js | |
t@@ -1 +1 @@ | |
-Search.setIndex({objects:{"":{sphere:[4,0,1,""]},sphere:{status:[4,2,1,""],con… | |
-\ No newline at end of file | |
+Search.setIndex({objects:{"":{sphere:[4,0,1,""]},sphere:{status:[4,2,1,""],con… | |
+\ No newline at end of file | |
diff --git a/doc/pdf/sphere.pdf b/doc/pdf/sphere.pdf | |
Binary files differ. | |
diff --git a/doc/sphinx/conf.py b/doc/sphinx/conf.py | |
t@@ -50,7 +50,7 @@ master_doc = 'index' | |
# General information about the project. | |
project = u'sphere' | |
-copyright = u'2012, Anders Damsgaard Christensen' | |
+copyright = u'2012, Anders Damsgaard' | |
# The version info for the project you're documenting, acts as replacement for | |
# |version| and |release|, also used in various other places throughout the | |
t@@ -193,7 +193,7 @@ latex_elements = { | |
# (source start file, target name, title, author, documentclass [howto/manual]… | |
latex_documents = [ | |
('index', 'sphere.tex', u'sphere Documentation', | |
- u'Anders Damsgaard Christensen', 'manual'), | |
+ u'Anders Damsgaard', 'manual'), | |
] | |
# The name of an image file (relative to this directory) to place at the top of | |
t@@ -223,7 +223,7 @@ latex_documents = [ | |
# (source start file, name, description, authors, manual section). | |
man_pages = [ | |
('index', 'sphere', u'sphere Documentation', | |
- [u'Anders Damsgaard Christensen'], 1) | |
+ [u'Anders Damsgaard'], 1) | |
] | |
# If true, show URL addresses after external links. | |
t@@ -237,7 +237,7 @@ man_pages = [ | |
# dir menu entry, description, category) | |
texinfo_documents = [ | |
('index', 'sphere', u'sphere Documentation', | |
- u'Anders Damsgaard Christensen', 'sphere', 'One line description of project… | |
+ u'Anders Damsgaard', 'sphere', 'One line description of project.', | |
'Miscellaneous'), | |
] | |
diff --git a/doc/sphinx/introduction.rst b/doc/sphinx/introduction.rst | |
t@@ -14,6 +14,7 @@ Requirements | |
The build requirements are: | |
* A Nvidia CUDA-supported version of Linux or Mac OS X (see the `CUDA toolki… | |
* `GNU Make <https://www.gnu.org/software/make/>`_ | |
+ * `CMake <http://www.cmake.org>`_ | |
* The `GNU Compiler Collection <http://gcc.gnu.org/>`_ (GCC) | |
* The `Nvidia CUDA toolkit and SDK <https://developer.nvidia.com/cuda-downlo… | |
t@@ -42,18 +43,21 @@ Optional tools, required for building the documentation: | |
Building *sphere* | |
----------------- | |
-All instructions required for building *sphere* are provided in a number of ``… | |
+All instructions required for building *sphere* are provided in a number of ``… | |
- $ cd src | |
- $ make | |
+ $ cmake . && make | |
-If successfull, the GNU Makefile will create the required data folders, object… | |
+If successfull, the Makefiles will create the required data folders, object fi… | |
- $ ./sphere_* --version | |
+ $ ./sphere --version | |
The output should look similar to this: | |
-.. program-output:: ../../sphere_linux_X86_64 --version | |
+.. program-output:: ../../sphere --version | |
+ | |
+The build can be verified by running a number of automated tests:: | |
+ | |
+ $ make test | |
The documentation can be read in the `reStructuredText <http://docutils.source… | |
diff --git a/python/bondtest.py b/python/bondtest.py | |
t@@ -1,44 +0,0 @@ | |
-#!/usr/bin/env python | |
- | |
-from sphere import * | |
- | |
-sb = Spherebin(np=2, sid='bondtest') | |
- | |
-cleanup(sb) | |
- | |
-sb.x[0,:] = numpy.array((2,2,2)) | |
-sb.x[1,:] = numpy.array((3.5,2,2)) | |
-sb.radius = numpy.ones(sb.np)*0.5 | |
- | |
-#sb.vel[1,2] = 1 | |
-sb.angvel[1,1] = 0.01 | |
- | |
- | |
-sb.initGridAndWorldsize(margin = 10, periodic = 1, contactmodel = 2, g = numpy… | |
- | |
-sb.bond(0, 1) | |
- | |
-sb.defaultParams() | |
-#sb.gamma_n[0] = 10000 | |
-#sb.initTemporal(total=4.0) | |
-sb.initTemporal(total=0.01, file_dt=2e-4) | |
- | |
-sb.writebin() | |
- | |
-sb.run(dry=True) | |
-sb.run() | |
- | |
-sb.render(verbose=False) | |
- | |
-visualize(sb.sid, "energy") | |
- | |
-sb.readlast() | |
-print(sb.bonds_delta_n) | |
-print(sb.bonds_delta_t) | |
-print(sb.bonds_omega_n) | |
-print(sb.bonds_omega_t) | |
-print() | |
-print(sb.force) | |
-print(sb.torque) | |
-print(sb.vel) | |
-print(sb.angvel) | |
diff --git a/python/shear-test.py b/python/shear-test.py | |
t@@ -5,13 +5,13 @@ from sphere import * | |
### EXPERIMENT SETUP ### | |
initialization = True | |
-consolidation = True | |
-shearing = True | |
-rendering = True | |
-plots = True | |
+consolidation = False | |
+shearing = False | |
+rendering = False | |
+plots = False | |
# Number of particles | |
-np = 2e3 | |
+np = 1e4 | |
# Common simulation id | |
sim_id = "shear-test" | |
t@@ -35,7 +35,7 @@ init.defaultParams(gamma_n = 0.0, mu_s = 0.4, mu_d = 0.4) | |
init.initRandomGridPos(gridnum = numpy.array([12, 12, 1000]), periodic = 1, co… | |
# Set duration of simulation | |
-init.initTemporal(total = 5.0) | |
+init.initTemporal(total = 0.2) | |
if (initialization == True): | |
# Write input file for sphere | |
diff --git a/src/sphere.cpp b/src/sphere.cpp | |
t@@ -621,15 +621,18 @@ void DEM::forcechains(const std::string format, const in… | |
<< "# the forcechain utility in sphere. For more information,\n" | |
<< "# see https://github.com/anders-dc/sphere\n" | |
<< "set size ratio -1\n"; | |
- if (format == "png") | |
- cout << "set term pngcairo size 50 cm,40 cm\n"; | |
- else if (format == "epslatex") { | |
+ if (format == "png") { | |
+ cout << "set term pngcairo size 30 cm,20 cm\n"; | |
+ cout << "set out '" << s << "-fc.png'\n"; | |
+ } else if (format == "epslatex") { | |
cout << "set term epslatex size 8.6 cm, 5.6 cm\n"; | |
- cout << "set out 'plots/" << s << "-fc.tex'\n"; | |
+ //cout << "set out 'plots/" << s << "-fc.tex'\n"; | |
+ cout << "set out '" << s << "-fc.tex'\n"; | |
} else if (format == "epslatex-color") { | |
//cout << "set term epslatex color size 12 cm, 8.6 cm\n"; | |
- cout << "set term epsla color size 8.6 cm, 5.6 cm\n"; | |
+ cout << "set term epslatex color size 8.6 cm, 5.6 cm\n"; | |
cout << "set out 'plots/" << s << "-fc.tex'\n"; | |
+ //cout << "set out '" << s << "-fc.tex'\n"; | |
} | |
cout << "set xlabel '\\sffamily $x_1$, [m]'\n"; | |
if (threedim == 1) { | |
diff --git a/tests/tests.py b/tests/tests.py | |
t@@ -1,114 +0,0 @@ | |
-#!/usr/bin/env python | |
-from sphere import * | |
-import subprocess | |
- | |
-def passed(): | |
- return "\tPassed" | |
- | |
-def failed(): | |
- return "\tFailed" | |
- | |
-def compare(first, second, string): | |
- if (first == second): | |
- print(string + passed()) | |
- else: | |
- print(string + failed()) | |
- | |
-def compareFloats(first, second, string, criterion=1e-5): | |
- if abs(first-second) < criterion: | |
- print(string + passed()) | |
- else : | |
- print(string + failed()) | |
- | |
-def cleanup(spherebin): | |
- 'Remove temporary files' | |
- subprocess.call("rm -f ../input/" + spherebin.sid + ".bin", shell=True) | |
- subprocess.call("rm -f ../output/" + spherebin.sid + ".*.bin", shell=True) | |
- print("") | |
- | |
- | |
-#### Input/output tests #### | |
-print("### Input/output tests ###") | |
- | |
-# Generate data in python | |
-orig = Spherebin(np = 100, nw = 1, sid = "test-initgrid") | |
-orig.generateRadii(histogram = False) | |
-orig.defaultParams() | |
-orig.initRandomGridPos(g = numpy.zeros(orig.nd)) | |
-orig.initTemporal(current = 0.0, total = 0.0) | |
-orig.time_total = 2.0*orig.time_dt; | |
-orig.time_file_dt = orig.time_dt; | |
-orig.writebin(verbose=False) | |
- | |
-# Test Python IO routines | |
-py = Spherebin() | |
-py.readbin("../input/" + orig.sid + ".bin", verbose=False) | |
-compare(orig, py, "Python IO:") | |
- | |
-# Test C++ IO routines | |
-orig.run(verbose=False, hideinputfile=True) | |
-#orig.run() | |
-cpp = Spherebin() | |
-cpp.readbin("../output/" + orig.sid + ".output00000.bin", verbose=False) | |
-compare(orig, cpp, "C++ IO: ") | |
- | |
-# Test CUDA IO routines | |
-cuda = Spherebin() | |
-cuda.readbin("../output/" + orig.sid + ".output00001.bin", verbose=False) | |
-cuda.time_current = orig.time_current | |
-cuda.time_step_count = orig.time_step_count | |
-compare(orig, cuda, "CUDA IO: ") | |
- | |
-# Remove temporary files | |
-cleanup(orig) | |
- | |
- | |
-#### Porosity tests #### | |
-print("### porosity tests ###") | |
- | |
-def testPorosities(spherebin): | |
- | |
- # Number of vertical slices | |
- slicevals = [1, 2, 4] | |
- i = 1 # iterator var | |
- for slices in slicevals: | |
- | |
- # Find correct value of bulk porosity | |
- n_bulk = spherebin.bulkPorosity() | |
- #print("Bulk: " + str(n_bulk)) | |
- | |
- porosity = spherebin.porosity(slices = slices)[0] | |
- #print("Avg: " + str(numpy.average(porosity))) | |
- #print(porosity) | |
- | |
- # Check if average of porosity function values matches the bulk porosi… | |
- compareFloats(n_bulk, numpy.average(porosity), \ | |
- spherebin.sid + ": Porosity average to bulk porosity ("\ | |
- + str(i) + "/" + str(len(slicevals)) + "):") | |
- i += 1 | |
- | |
-# Test data from previous test | |
-testPorosities(orig) | |
- | |
-# Simple cubic packing of uniform spheres | |
-# The theoretical porosity is (4/3*pi*r^3)/(2r)^3 = 0.476 | |
-sidelen = 10 | |
-cubic = Spherebin(np = sidelen**3, sid='cubic') | |
-radius = 1.0 | |
-cubic.generateRadii(psd='uni', radius_mean=radius, radius_variance=0.0, histog… | |
-for ix in range(sidelen): | |
- for iy in range(sidelen): | |
- for iz in range(sidelen): | |
- i = ix + sidelen * (iy + sidelen * iz) # linear index | |
- cubic.x[i,0] = ix*radius*2.0 + radius | |
- cubic.x[i,1] = iy*radius*2.0 + radius | |
- cubic.x[i,2] = iz*radius*2.0 + radius | |
-cubic.L[:] = 2.0 * radius * sidelen | |
- | |
-cubic.initTemporal(0.2) | |
-cubic.initGrid() | |
- | |
-testPorosities(cubic) | |
- | |
-cleanup(cubic) | |
- |