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

New shape: Quarterpipe #3960

Closed
Closed
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
Binary file added doc/doxygen/figs/quarterpipe_detailed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 30 additions & 0 deletions doc/sphinx/constraints.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ Available shapes are listed below.
- :class:`espressomd.shapes.SpheroCylinder`
- :class:`espressomd.shapes.Torus`
- :class:`espressomd.shapes.HollowConicalFrustum`
- :class:`espressomd.shapes.Quarterpipe`
- :class:`espressomd.shapes.Union`


Expand Down Expand Up @@ -450,6 +451,35 @@ Note: in the OpenGL visualizer, if the OpenGL Extrusion library is not available
the shape surface will be rendered with dots.


Quarterpipe
""""""""""""

:class:`espressomd.shapes.Quarterpipe`

A quarterpipe which can be used to connect two walls or rhomboids in a smooth way.
The shape is constructed by removing a quarter cylinder of radius ``radius``
from a cuboid with side length ``radius``.
It can be created via ::

shape=espressomd.shapes.Quarterpipe(center=[25]*3, axis=[1, 0, 0],
orientation=[0, 1, 1], radius=25,
height=30)

A cross section with an explanation of the parameters is shown in the figure below.
The three-dimensional shape is an extrusion of this profile.

.. figure:: figures/quarterpipe.png
:alt: Cross section of the quarterpipe shape.
:height: 4.00000cm

``center`` defines the center of the cylinder.
``axis`` is the axis of the cylinder, orthogonal to the curve of the pipe.
``orientation`` points from ``center`` along the symmetry axis of the quarterpipe.
``radius`` is the radius of the pipe.
``height`` is the extent of the shape along ``axis`` (symmetric in both directions
starting from ``center``).


Union
"""""

Expand Down
Binary file added doc/sphinx/figures/quarterpipe.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 9 additions & 1 deletion samples/visualization_constraints.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
group.add_argument("--wall", action="store_const", dest="shape", const="Wall",
default="Wall")
for shape in ("Sphere", "Ellipsoid", "Cylinder", "SpheroCylinder", "Torus",
"SimplePore", "Slitpore", "HollowConicalFrustum"):
"SimplePore", "Slitpore", "HollowConicalFrustum", "Quarterpipe"):
group.add_argument("--" + shape.lower(), action="store_const",
dest="shape", const=shape)
args = parser.parse_args()
Expand Down Expand Up @@ -107,6 +107,14 @@
direction=1, radius=15, tube_radius=6),
particle_type=0, penetrable=True)

elif args.shape == "Quarterpipe":
system.constraints.add(
shape=espressomd.shapes.Quarterpipe(center=[25, 3, 3], axis=[1, 0, 0],
orientation=[0, 1, 1], radius=40,
height=50),
particle_type=0, penetrable=True)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • I'm not sure it is a good idea to have two sharp edges in a shape interacting with a LJ liquid; wouldn't it be safer to have e.g. 4 quaterpipes to form a pipe, or a quaterpipe with its X,Y,Z edge lengths equal to the box lengths?
  • the rasterization doesn't draw dots on the shape top and bottom surfaces, giving the impression the shape is hollow.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the shape becomes unsafe when side walls touch the periodic boundaries. Then Particles can enter the interaction region from the other side and pick up a lot of potential energy that propels them through the box. I will change the height though to hide the top/bottom



else:
raise ValueError("Unknown shape '{}'".format(args.shape))

Expand Down
22 changes: 22 additions & 0 deletions src/python/espressomd/shapes.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,28 @@ class Shape:
_so_bind_methods = ("calc_distance",)


@script_interface_register
class Quarterpipe(Shape, ScriptInterfaceHelper):
"""
A quarterpipe, built by subtracting a ``pi/2`` segment of a cylinder from a cuboid

Attributes
----------
center : (3,) array_like of :obj:`float`
Coordinates of the center of the quarterpipe.
axis : (3,) array_like of :obj:`float`
Axis of the cylinder.
orientation : (3,) array_like of :obj:`float`
direction in which the quarterpipe points from center
radius : :obj:`float`
Radius of the pipe.
height : :obj:`float`
height of the quarterpipe along ``axis``

"""
_so_name = "Shapes::Quarterpipe"


@script_interface_register
class Cylinder(Shape, ScriptInterfaceHelper):
"""
Expand Down
74 changes: 74 additions & 0 deletions src/script_interface/shapes/Quarterpipe.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
* Copyright (C) 2010-2019 The ESPResSo project
*
* This file is part of ESPResSo.
*
* ESPResSo is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ESPResSo is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef ESPRESSO_QUARTERPIPE_HPP
#define ESPRESSO_QUARTERPIPE_HPP
#include "Shape.hpp"
#include <shapes/Quarterpipe.hpp>

namespace ScriptInterface {
namespace Shapes {

class Quarterpipe : public Shape {
public:
Quarterpipe() : m_quarterpipe(new ::Shapes::Quarterpipe()) {
add_parameters({{"center",
[this](Variant const &v) {
m_quarterpipe->set_center(get_value<Utils::Vector3d>(v));
},
[this]() { return m_quarterpipe->center(); }},

{"axis",
[this](Variant const &v) {
m_quarterpipe->set_axis(get_value<Utils::Vector3d>(v));
},
[this]() { return m_quarterpipe->axis(); }},

{"orientation",
[this](Variant const &v) {
m_quarterpipe->set_orientation(
get_value<Utils::Vector3d>(v));
},
[this]() { return m_quarterpipe->orientation(); }},

{"radius",
[this](Variant const &v) {
m_quarterpipe->set_radius(get_value<double>(v));
},
[this]() { return m_quarterpipe->radius(); }},

{"height",
[this](Variant const &v) {
m_quarterpipe->set_height(get_value<double>(v));
},
[this]() { return m_quarterpipe->height(); }}});
}

std::shared_ptr<::Shapes::Shape> shape() const override {
return m_quarterpipe;
}

private:
std::shared_ptr<::Shapes::Quarterpipe> m_quarterpipe;
};

} /* namespace Shapes */
} /* namespace ScriptInterface */

#endif
2 changes: 2 additions & 0 deletions src/script_interface/shapes/initialize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "Ellipsoid.hpp"
#include "HollowConicalFrustum.hpp"
#include "NoWhere.hpp"
#include "Quarterpipe.hpp"
#include "Rhomboid.hpp"
#include "SimplePore.hpp"
#include "Slitpore.hpp"
Expand All @@ -35,6 +36,7 @@
namespace ScriptInterface {
namespace Shapes {
void initialize(Utils::Factory<ObjectHandle> *f) {
f->register_new<Quarterpipe>("Shapes::Quarterpipe");
f->register_new<HollowConicalFrustum>("Shapes::HollowConicalFrustum");
f->register_new<Union>("Shapes::Union");
f->register_new<NoWhere>("Shapes::NoWhere");
Expand Down
6 changes: 3 additions & 3 deletions src/shapes/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
set(SOURCE_FILES
src/HollowConicalFrustum.cpp src/Cylinder.cpp src/Ellipsoid.cpp
src/Rhomboid.cpp src/SimplePore.cpp src/Slitpore.cpp src/Sphere.cpp
src/SpheroCylinder.cpp src/Torus.cpp src/Wall.cpp)
src/Quarterpipe.cpp src/HollowConicalFrustum.cpp src/Cylinder.cpp
src/Ellipsoid.cpp src/Rhomboid.cpp src/SimplePore.cpp src/Slitpore.cpp
src/Sphere.cpp src/SpheroCylinder.cpp src/Torus.cpp src/Wall.cpp)

add_library(EspressoShapes SHARED ${SOURCE_FILES})
target_link_libraries(EspressoShapes PUBLIC EspressoUtils PRIVATE Boost::boost
Expand Down
74 changes: 74 additions & 0 deletions src/shapes/include/shapes/Quarterpipe.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
* Copyright (C) 2017-2019 The ESPResSo project
*
* This file is part of ESPResSo.
*
* ESPResSo is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ESPResSo is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef SHAPES_QUARTERPIPE_HPP
#define SHAPES_QUARTERPIPE_HPP

#include "Shape.hpp"
#include <utils/Vector.hpp>
#include <utils/constants.hpp>

namespace Shapes {

/**
* @brief Quarterpipe shape based on intersecting a cuboid
* with a cylinder
*
* \image html quarterpipe_detailed.png width=1000px
*/

class Quarterpipe : public Shape {
public:
Quarterpipe()
: m_center{Utils::Vector3d{}}, m_axis{Utils::Vector3d{}},
m_orientation{Utils::Vector3d{}}, m_radius(0.), m_height(0.),
m_delta_phi(0.5 * Utils::pi()) {}

void set_center(Utils::Vector3d const &center) { m_center = center; }
void set_axis(Utils::Vector3d const &axis) {
auto axis_tmp(axis);
m_axis = axis_tmp.normalize();
}
void set_orientation(Utils::Vector3d const &orientation) {
auto orientation_tmp(orientation);
m_orientation = orientation_tmp.normalize();
}
void set_radius(double const radius) { m_radius = radius; }
void set_height(double const height) { m_height = height; }

Utils::Vector3d const &center() const { return m_center; }
Utils::Vector3d const &axis() const { return m_axis; }
Utils::Vector3d const &orientation() const { return m_orientation; }
double radius() const { return m_radius; }
double height() const { return m_height; }

void calculate_dist(const Utils::Vector3d &pos, double &dist,
Utils::Vector3d &vec) const override;

private:
Utils::Vector3d m_center;
Utils::Vector3d m_axis;
Utils::Vector3d m_orientation;
double m_radius;
double m_height;
double m_delta_phi;
};
} // namespace Shapes

#endif
Loading