Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openstructure
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
schwede
openstructure
Commits
1324cba2
Commit
1324cba2
authored
11 years ago
by
Niklaus Johner
Browse files
Options
Downloads
Patches
Plain Diff
Rename basis_vec to ucell_size in the geom functions using Periodic boundary conditions
in view of adding PBC for non-orthogonal cells
parent
d419feee
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
modules/geom/src/vecmat3_op.cc
+9
-9
9 additions, 9 deletions
modules/geom/src/vecmat3_op.cc
modules/geom/src/vecmat3_op.hh
+11
-11
11 additions, 11 deletions
modules/geom/src/vecmat3_op.hh
with
20 additions
and
20 deletions
modules/geom/src/vecmat3_op.cc
+
9
−
9
View file @
1324cba2
...
...
@@ -208,20 +208,20 @@ Real MinDistance(const Vec3List& l1, const Vec3List& l2)
return
std
::
sqrt
(
min
);
}
Real
MinDistanceWithPBC
(
const
Vec3List
&
l1
,
const
Vec3List
&
l2
,
Vec3
&
basis_vec
)
Real
MinDistanceWithPBC
(
const
Vec3List
&
l1
,
const
Vec3List
&
l2
,
Vec3
&
ucell_size
)
{
// returns the minimal distance between two sets of points (Vec3List)
// given the periodic boundary condition along x,y,z given in the
basis_vec
// given the periodic boundary condition along x,y,z given in the
ucell_size
if
(
l1
.
size
()
==
0
||
l2
.
size
()
==
0
){
throw
GeomException
(
"cannot calculate minimal distance: empty Vec3List"
);}
Real
min
=
Length2
(
*
l1
.
begin
()
-*
l2
.
begin
());
Real
d
;
Vec3
v
;
for
(
int
i
=
0
;
i
<
3
;
i
++
)
{
basis_vec
[
i
]
=
std
::
fabs
(
basis_vec
[
i
]);
ucell_size
[
i
]
=
std
::
fabs
(
ucell_size
[
i
]);
}
for
(
Vec3List
::
const_iterator
p1
=
l1
.
begin
(),
e1
=
l1
.
end
();
p1
!=
e1
;
p1
++
)
{
for
(
Vec3List
::
const_iterator
p2
=
l2
.
begin
(),
e2
=
l2
.
end
();
p2
!=
e2
;
p2
++
)
{
d
=
Distance2WithPBC
(
*
p1
,
*
p2
,
basis_vec
);
d
=
Distance2WithPBC
(
*
p1
,
*
p2
,
ucell_size
);
if
(
d
<
min
)
min
=
d
;
}
}
...
...
@@ -268,22 +268,22 @@ Vec3List CalculateUnitCellVectors(const Vec3& ucell_size, const Vec3& ucell_angl
return
ucell_vec
;
}
Vec3
WrapVec3
(
const
Vec3
&
v1
,
const
Vec3
&
box_center
,
const
Vec3
&
basis_vec
){
Vec3
WrapVec3
(
const
Vec3
&
v1
,
const
Vec3
&
box_center
,
const
Vec3
&
ucell_size
){
Vec3
v
;
Real
r
;
for
(
int
i
=
0
;
i
<
3
;
i
++
)
{
r
=
(
v1
[
i
]
-
box_center
[
i
])
/
basis_vec
[
i
];
r
=
(
v1
[
i
]
-
box_center
[
i
])
/
ucell_size
[
i
];
r
=
(
r
>
0.0
)
?
std
::
floor
(
r
+
0.5
)
:
std
::
ceil
(
r
-
0.5
);
v
[
i
]
=
v1
[
i
]
-
basis_vec
[
i
]
*
r
;
v
[
i
]
=
v1
[
i
]
-
ucell_size
[
i
]
*
r
;
}
return
v
;
}
Vec3List
WrapVec3List
(
const
Vec3List
&
vl
,
const
Vec3
&
box_center
,
const
Vec3
&
basis_vec
){
Vec3List
WrapVec3List
(
const
Vec3List
&
vl
,
const
Vec3
&
box_center
,
const
Vec3
&
ucell_size
){
Vec3List
vl_out
;
vl_out
.
reserve
(
vl_out
.
size
());
for
(
Vec3List
::
const_iterator
v1
=
vl
.
begin
(),
e
=
vl
.
end
();
v1
!=
e
;
v1
++
)
{
vl_out
.
push_back
(
WrapVec3
(
*
v1
,
box_center
,
basis_vec
));
vl_out
.
push_back
(
WrapVec3
(
*
v1
,
box_center
,
ucell_size
));
}
return
vl_out
;
}
...
...
This diff is collapsed.
Click to expand it.
modules/geom/src/vecmat3_op.hh
+
11
−
11
View file @
1324cba2
...
...
@@ -195,35 +195,35 @@ inline Real Distance(const Vec3& p1, const Vec3& p2)
}
//! return the squared distance between two points with periodic boundaries in x,y,z given in
basis_vec
inline
Real
Distance2WithPBC
(
const
Vec3
&
v1
,
const
Vec3
&
v2
,
const
Vec3
&
basis_vec
){
//! return the squared distance between two points with periodic boundaries in x,y,z given in
ucell_size
inline
Real
Distance2WithPBC
(
const
Vec3
&
v1
,
const
Vec3
&
v2
,
const
Vec3
&
ucell_size
){
Vec3
v
;
v
=
v1
-
v2
;
for
(
int
i
=
0
;
i
<
3
;
i
++
)
{
if
(
std
::
fabs
(
v
[
i
])
>
basis_vec
[
i
]
/
2.
){
v
[
i
]
=
std
::
fabs
(
v
[
i
])
-
basis_vec
[
i
]
*
int
(
std
::
fabs
(
v
[
i
])
/
basis_vec
[
i
]
+
0.5
);
if
(
std
::
fabs
(
v
[
i
])
>
ucell_size
[
i
]
/
2.
){
v
[
i
]
=
std
::
fabs
(
v
[
i
])
-
ucell_size
[
i
]
*
int
(
std
::
fabs
(
v
[
i
])
/
ucell_size
[
i
]
+
0.5
);
}
}
return
Length2
(
v
);
}
//! return the distance between two points with periodic boundaries in x,y,z given in
basis_vec
inline
Real
DistanceWithPBC
(
const
Vec3
&
v1
,
const
Vec3
&
v2
,
const
Vec3
&
basis_vec
){
return
sqrt
(
Distance2WithPBC
(
v1
,
v2
,
basis_vec
));
//! return the distance between two points with periodic boundaries in x,y,z given in
ucell_size
inline
Real
DistanceWithPBC
(
const
Vec3
&
v1
,
const
Vec3
&
v2
,
const
Vec3
&
ucell_size
){
return
sqrt
(
Distance2WithPBC
(
v1
,
v2
,
ucell_size
));
}
//! returns the minimal distance between the points in two Vec3List
Real
DLLEXPORT_OST_GEOM
MinDistance
(
const
Vec3List
&
l1
,
const
Vec3List
&
l2
);
//! returns the minimal distance between the points in two Vec3List
// with periodic boundaries in x,y,z given in
basis_vec
Real
DLLEXPORT_OST_GEOM
MinDistanceWithPBC
(
const
Vec3List
&
l1
,
const
Vec3List
&
l2
,
Vec3
&
basis_vec
);
// with periodic boundaries in x,y,z given in
ucell_size
Real
DLLEXPORT_OST_GEOM
MinDistanceWithPBC
(
const
Vec3List
&
l1
,
const
Vec3List
&
l2
,
Vec3
&
ucell_size
);
//! returns the indices index1, index2 corresponding to the points in
//! the Vec3List l1 and l2 having the minimal distance.
std
::
vector
<
unsigned
int
>
DLLEXPORT_OST_GEOM
MinDistanceIndices
(
const
Vec3List
&
l1
,
const
Vec3List
&
l2
);
//! Calculates the Unit Cell Vectors from their sizes and angles (given as Vec3(gamma,beta,alpha)).
Vec3List
DLLEXPORT_OST_GEOM
CalculateUnitCellVectors
(
const
Vec3
&
ucell_size
,
const
Vec3
&
ucell_angles
);
//!wraps a vector in a box with periodic boundaries
Vec3
DLLEXPORT_OST_GEOM
WrapVec3
(
const
Vec3
&
v1
,
const
Vec3
&
box_center
,
const
Vec3
&
basis_vec
);
Vec3
DLLEXPORT_OST_GEOM
WrapVec3
(
const
Vec3
&
v1
,
const
Vec3
&
box_center
,
const
Vec3
&
ucell_size
);
//!wraps all the verctors in a Vec3List in a box with periodic boundaries
Vec3List
DLLEXPORT_OST_GEOM
WrapVec3List
(
const
Vec3List
&
vl
,
const
Vec3
&
box_center
,
const
Vec3
&
basis_vec
);
Vec3List
DLLEXPORT_OST_GEOM
WrapVec3List
(
const
Vec3List
&
vl
,
const
Vec3
&
box_center
,
const
Vec3
&
ucell_size
);
}
// ns
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment