Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing bugs #10

Merged
merged 6 commits into from
Jun 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions docs/tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,15 @@ the drop-down menu as follows::
Select the file and click on ``Import PLY``. You should now see something
similar as to the image below.

.. figure:: _static/img/tutorials/genus2_blender_01.jpg
.. figure:: _static/img/tutorials/genus2_blender_01.JPG
:alt: The imported Genus 2 isosurface in Blender.

Finally, we assign a material to the object, tune the camera to bring the
object fully into view, set the color of the background to black, add
two sun-type light sources and set the film to transparent. For the material,
we have used the settings as can be seen in the figure below.

.. figure:: _static/img/tutorials/genus2_blender_02.jpg
.. figure:: _static/img/tutorials/genus2_blender_02.JPG
:alt: The imported Genus 2 isosurface in Blender.

The only step that remains is to render the image, which will give the image
Expand Down Expand Up @@ -174,7 +174,7 @@ Observe that two isosurfaces are created and stored as ``.ply`` files:

Importing these two files in Blender gives us the following result

.. figure:: _static/img/tutorials/benzene_homo_blender_01.JPG
.. figure:: _static/img/tutorials/benzene_homo_blender_01.jpg
:alt: HOMO orbital of benzene imported into Blender

Of course, this result is rather blend and we would like to add
Expand Down Expand Up @@ -253,7 +253,7 @@ This will generate all the atoms and bonds between them. Next,
materials are assigned to all atoms and bonds and the final result
looks as seen in the image below.

.. figure:: _static/img/tutorials/benzene_homo_blender_02.JPG
.. figure:: _static/img/tutorials/benzene_homo_blender_02.jpg
:alt: HOMO orbital of benzene together with the atoms and bonds

Finally, we can render the scene to create a nice picture of the molecular orbital.
Expand Down
Binary file added img/comparison_mc_mt.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ execute_process(
SET(PROGNAME "DEN2OBJ")
SET(VERSION_MAJOR "1")
SET(VERSION_MINOR "2")
SET(VERSION_MICRO "0")
SET(VERSION_MICRO "1")
message(STATUS "Writing configuration file in: ${CMAKE_CURRENT_SOURCE_DIR}/config.h")
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_SOURCE_DIR}/config.h @ONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/den2obj.pc.in ${CMAKE_BINARY_DIR}/den2obj.pc @ONLY)
Expand Down
12 changes: 9 additions & 3 deletions src/den2obj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ int main(int argc, char* argv[]) {
TCLAP::ValueArg<std::string> arg_generator("g","dataset","Dataset name",false,"","string");
cmd.add(arg_generator);

// select compression algorithm
TCLAP::ValueArg<std::string> arg_algo("a","algo","Compression algorithm",false,"","string");
// select algorithm for either compression or for tesselation
TCLAP::ValueArg<std::string> arg_algo("a","algo","Algorithm selection",false,"","string");
cmd.add(arg_algo);

cmd.parse(argc, argv);
Expand Down Expand Up @@ -237,7 +237,13 @@ int main(int argc, char* argv[]) {
output_filename = stem.string().substr(0,stem.string().size()-4) + "_neg" + ext.string();

IsoSurface is_neg(sf.get());
is_neg.marching_cubes(-isovalue);
if(arg_algo.getValue().empty() || arg_algo.getValue() == "marching-cubes") {
is_neg.marching_cubes(-isovalue);
} else if(arg_algo.getValue() == "marching-tetrahedra") {
is_neg.marching_tetrahedra(-isovalue);
} else {
throw std::runtime_error("Invalid isosurface generation algo: " + arg_algo.getValue());
}

IsoSurfaceMesh ism_neg(sf.get(), &is_neg);
ism_neg.construct_mesh(arg_c.getValue());
Expand Down
14 changes: 10 additions & 4 deletions src/generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void Generator::build_dataset(const std::string& name,
mo_id = 21;
}

const unsigned int npts = 150;
const unsigned int npts = 100;
const fpt sz = 6.0f;
std::array<unsigned int, 3> grid_dimensions = {npts, npts, npts};
std::vector<fpt> grid = this->benzene_molecular_orbital(sz, npts, mo_id);
Expand Down Expand Up @@ -103,19 +103,22 @@ std::vector<fpt> Generator::genus2(fpt sz, size_t npts) const {

// build grid
std::vector<fpt> f(npts*npts*npts);
#pragma omp parallel for schedule(static)
for(unsigned int i=0; i<npts; i++) { // loop over z
const float z = xx[i];
boost::timer::progress_display progress(npts);
for(unsigned int j=0; j<npts; j++) { // loop over y
const float y = xx[j];
#pragma omp parallel for schedule(static)
for(unsigned int k=0; k<npts; k++) { // loop over x
const float x = xx[k];
const unsigned int idx = i * npts * npts + j * npts + k;
f[idx] = 2 * y * (y*y - 3 * x*x) * (1 - z*z) +
(x*x + y*y) * (x*x + y*y) - (9*z*z - 1) * (1 - z*z);
}
}
++progress;
}
std::cout << std::endl;

return f;
}
Expand All @@ -140,18 +143,21 @@ std::vector<fpt> Generator::benzene_molecular_orbital(fpt sz, size_t npts,

// build grid
std::vector<fpt> f(npts*npts*npts);
#pragma omp parallel for schedule(static)
boost::timer::progress_display progress(npts);
for(unsigned int i=0; i<npts; i++) { // loop over z
const float z = xx[i];
for(unsigned int j=0; j<npts; j++) { // loop over y
const float y = xx[j];
#pragma omp parallel for schedule(static)
for(unsigned int k=0; k<npts; k++) { // loop over x
const float x = xx[k];
const unsigned int idx = i * npts * npts + j * npts + k;
const unsigned int idx = (i * npts * npts) + (j * npts) + k;
f[idx] = this->calculate_mo_amp(Vec3(x,y,z), mo_id);
}
}
++progress;
}
std::cout << std::endl;

return f;
}
Expand Down
1 change: 1 addition & 0 deletions src/generator.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

#include <boost/math/constants/constants.hpp>
#include <boost/math/special_functions/factorials.hpp>
#include <boost/timer/progress_display.hpp>

#include "d2o_format.h"
#include "generator_benzene_data.h"
Expand Down
Loading