ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
lees_edwards.hpp
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2021-2022 The ESPResSo project
3
*
4
* This file is part of ESPResSo.
5
*
6
* ESPResSo is free software: you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation, either version 3 of the License, or
9
* (at your option) any later version.
10
*
11
* ESPResSo is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with this program. If not, see <http://www.gnu.org/licenses/>.
18
*/
19
20
#pragma once
21
22
#include "
BoxGeometry.hpp
"
23
#include "
Particle.hpp
"
24
#include "
lees_edwards/protocols.hpp
"
25
#include "system/Leaf.hpp"
26
27
#include <cmath>
28
#include <memory>
29
30
namespace
LeesEdwards
{
31
class
UpdateOffset
{
32
protected
:
33
LeesEdwardsBC
const
&
m_le
;
34
35
public
:
36
UpdateOffset
(
BoxGeometry
const
&box) :
m_le
{box.lees_edwards_bc()} {}
37
38
void
operator()
(
Particle
&p,
double
pos_prefactor = 1.0)
const
{
39
// Disabled as long as we do not use a two step LE update
40
}
41
};
42
43
class
Push
:
public
UpdateOffset
{
44
BoxGeometry
const
&m_box;
45
46
public
:
47
Push
(
BoxGeometry
const
&box) :
UpdateOffset
{box}, m_box{box} {}
48
49
void
operator()
(
Particle
&p,
double
pos_prefactor = 1.0)
const
{
50
// Lees-Edwards acts at the zero step for the velocity half update and at
51
// the midstep for the position.
52
//
53
// The update of the velocity at the end of the time step is triggered by
54
// the flag and occurs in @ref propagate_vel_finalize_p_inst
55
if
(p.
pos
()[
m_le
.
shear_plane_normal
] >=
56
m_box.
length
()[
m_le
.
shear_plane_normal
]) {
57
p.
lees_edwards_flag
() = -1;
// perform a negative half velocity shift
58
}
else
if
(p.
pos
()[
m_le
.
shear_plane_normal
] < 0) {
59
p.
lees_edwards_flag
() = 1;
// perform a positive half velocity shift
60
}
else
{
61
p.
lees_edwards_flag
() = 0;
62
}
63
64
auto
const
dir =
static_cast<
double
>
(p.
lees_edwards_flag
());
65
p.
v
()[
m_le
.
shear_direction
] += dir *
m_le
.
shear_velocity
;
66
p.
pos
()[
m_le
.
shear_direction
] += pos_prefactor * dir *
m_le
.
pos_offset
;
67
p.
lees_edwards_offset
() -= pos_prefactor * dir *
m_le
.
pos_offset
;
68
m_box.
fold_position
(p.
pos
(), p.
image_box
());
69
// UpdateOffset::operator()(p,pos_prefactor);
70
}
71
};
72
73
inline
double
velocity_shift
(
short
int
le_flag,
BoxGeometry
const
&box) {
74
if
(box.
type
() !=
BoxType::LEES_EDWARDS
)
75
return
0.;
76
77
return
le_flag * box.
lees_edwards_bc
().
shear_velocity
;
78
}
79
80
inline
Utils::Vector3d
shear_direction
(
BoxGeometry
const
&box) {
81
return
Utils::unit_vector<double>(box.
lees_edwards_bc
().
shear_direction
);
82
}
83
84
inline
Utils::Vector3d
verlet_list_offset
(
BoxGeometry
const
&box,
85
double
pos_offset_at_last_resort) {
86
if
(box.
type
() ==
BoxType::LEES_EDWARDS
) {
87
return
shear_direction
(box) * std::fabs(box.
lees_edwards_bc
().
pos_offset
-
88
pos_offset_at_last_resort);
89
}
90
return
{};
91
}
92
93
class
LeesEdwards
:
public
System::Leaf
<LeesEdwards> {
94
std::shared_ptr<ActiveProtocol> m_protocol;
95
96
public
:
97
/** @brief Get currently active Lees-Edwards protocol. */
98
auto
get_protocol
()
const
{
return
m_protocol; }
99
100
/** @brief Set a new Lees-Edwards protocol. */
101
void
set_protocol(std::shared_ptr<ActiveProtocol> protocol);
102
103
/** @brief Delete the currently active Lees-Edwards protocol. */
104
void
unset_protocol();
105
106
void
update_box_params(
BoxGeometry
&box_geo,
double
sim_time);
107
};
108
109
}
// namespace LeesEdwards
BoxGeometry.hpp
BoxType::LEES_EDWARDS
@ LEES_EDWARDS
Particle.hpp
BoxGeometry
Definition
BoxGeometry.hpp:98
BoxGeometry::length
Utils::Vector3d const & length() const
Box length.
Definition
BoxGeometry.hpp:154
BoxGeometry::lees_edwards_bc
LeesEdwardsBC const & lees_edwards_bc() const
Definition
BoxGeometry.hpp:231
BoxGeometry::type
BoxType type() const
Definition
BoxGeometry.hpp:228
BoxGeometry::fold_position
void fold_position(Utils::Vector3d &pos, Utils::Vector3i &image_box) const
Fold coordinates to primary simulation box in-place.
Definition
BoxGeometry.hpp:267
LeesEdwards::LeesEdwards::get_protocol
auto get_protocol() const
Get currently active Lees-Edwards protocol.
Definition
lees_edwards.hpp:98
LeesEdwards::Push
Definition
lees_edwards.hpp:43
LeesEdwards::Push::Push
Push(BoxGeometry const &box)
Definition
lees_edwards.hpp:47
LeesEdwards::Push::operator()
void operator()(Particle &p, double pos_prefactor=1.0) const
Definition
lees_edwards.hpp:49
LeesEdwards::UpdateOffset
Definition
lees_edwards.hpp:31
LeesEdwards::UpdateOffset::m_le
LeesEdwardsBC const & m_le
Definition
lees_edwards.hpp:33
LeesEdwards::UpdateOffset::operator()
void operator()(Particle &p, double pos_prefactor=1.0) const
Definition
lees_edwards.hpp:38
LeesEdwards::UpdateOffset::UpdateOffset
UpdateOffset(BoxGeometry const &box)
Definition
lees_edwards.hpp:36
System::Leaf
Abstract class that represents a component of the system.
Definition
core/system/Leaf.hpp:34
Utils::Vector
Definition
Vector.hpp:48
LeesEdwards
Definition
integrate.cpp:93
LeesEdwards::verlet_list_offset
Utils::Vector3d verlet_list_offset(BoxGeometry const &box, double pos_offset_at_last_resort)
Definition
lees_edwards.hpp:84
LeesEdwards::velocity_shift
double velocity_shift(short int le_flag, BoxGeometry const &box)
Definition
lees_edwards.hpp:73
LeesEdwards::shear_direction
Utils::Vector3d shear_direction(BoxGeometry const &box)
Definition
lees_edwards.hpp:80
protocols.hpp
LeesEdwardsBC
Definition
LeesEdwardsBC.hpp:28
LeesEdwardsBC::shear_velocity
double shear_velocity
Definition
LeesEdwardsBC.hpp:31
LeesEdwardsBC::pos_offset
double pos_offset
Definition
LeesEdwardsBC.hpp:30
LeesEdwardsBC::shear_plane_normal
unsigned int shear_plane_normal
Definition
LeesEdwardsBC.hpp:33
LeesEdwardsBC::shear_direction
unsigned int shear_direction
Definition
LeesEdwardsBC.hpp:32
Particle
Struct holding all information for one particle.
Definition
Particle.hpp:395
Particle::lees_edwards_offset
auto const & lees_edwards_offset() const
Definition
Particle.hpp:446
Particle::lees_edwards_flag
auto const & lees_edwards_flag() const
Definition
Particle.hpp:448
Particle::v
auto const & v() const
Definition
Particle.hpp:433
Particle::image_box
auto const & image_box() const
Definition
Particle.hpp:444
Particle::pos
auto const & pos() const
Definition
Particle.hpp:431
src
core
lees_edwards
lees_edwards.hpp
Generated on Thu Dec 19 2024 02:13:16 for ESPResSo by
1.9.8