Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
lammps
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
multiscale
lammps
Commits
fba165d6
Commit
fba165d6
authored
6 years ago
by
Rene Halver
Browse files
Options
Downloads
Patches
Plain Diff
changed the files according to remarks by Steve (compare to previous commit)
parent
a62b6509
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/USER-SCAFACOS/scafacos.cpp
+34
-40
34 additions, 40 deletions
src/USER-SCAFACOS/scafacos.cpp
src/USER-SCAFACOS/scafacos.h
+1
-1
1 addition, 1 deletion
src/USER-SCAFACOS/scafacos.h
with
35 additions
and
41 deletions
src/USER-SCAFACOS/scafacos.cpp
+
34
−
40
View file @
fba165d6
...
@@ -38,16 +38,24 @@ using namespace LAMMPS_NS;
...
@@ -38,16 +38,24 @@ using namespace LAMMPS_NS;
Scafacos
::
Scafacos
(
LAMMPS
*
lmp
,
int
narg
,
char
**
arg
)
:
KSpace
(
lmp
,
narg
,
arg
)
Scafacos
::
Scafacos
(
LAMMPS
*
lmp
,
int
narg
,
char
**
arg
)
:
KSpace
(
lmp
,
narg
,
arg
)
{
{
if
(
narg
!=
2
)
error
->
all
(
FLERR
,
"Illegal scafacos command"
);
if
(
narg
>
2
)
error
->
all
(
FLERR
,
"Illegal scafacos command"
);
int
n
=
strlen
(
arg
[
0
])
+
1
;
int
n
=
strlen
(
arg
[
0
])
+
1
;
method
=
new
char
[
n
];
method
=
new
char
[
n
];
strcpy
(
method
,
arg
[
0
]);
strcpy
(
method
,
arg
[
0
]);
tolerance
=
force
->
numeric
(
FLERR
,
arg
[
1
]);
// to allow 'kspace scafacos <method>' with default values
if
(
narg
==
2
)
tolerance
=
force
->
numeric
(
FLERR
,
arg
[
1
]);
else
tolerance
=
0.001
;
// optional ScaFaCoS library setting defaults
// optional ScaFaCoS library setting defaults
// choose the correct default tolerance type for chosen method
tolerance_type
=
FCS_TOLERANCE_TYPE_FIELD
;
// TODO: needs to be expanded for all solvers, currently mainly used ones
if
(
strcmp
(
method
,
"fmm"
)
==
0
)
tolerance_type
=
FCS_TOLERANCE_TYPE_ENERGY
;
else
if
(
strcmp
(
method
,
"p3m"
)
==
0
||
strcmp
(
method
,
"p2nfft"
)
==
0
)
tolerance_type
=
FCS_TOLERANCE_TYPE_FIELD
;
// initializations
// initializations
...
@@ -68,7 +76,8 @@ Scafacos::~Scafacos()
...
@@ -68,7 +76,8 @@ Scafacos::~Scafacos()
memory
->
destroy
(
epot
);
memory
->
destroy
(
epot
);
memory
->
destroy
(
efield
);
memory
->
destroy
(
efield
);
// RENE: any clean-up/shut-down call to ScaFaCoS needed?
// clean up of the ScaFaCoS handle and internal arrays
fcs_destroy
(
fcs
);
}
}
/* ---------------------------------------------------------------------- */
/* ---------------------------------------------------------------------- */
...
@@ -93,7 +102,6 @@ void Scafacos::init()
...
@@ -93,7 +102,6 @@ void Scafacos::init()
// one-time initialization of ScaFaCoS
// one-time initialization of ScaFaCoS
scale
=
1.0
;
qqrd2e
=
force
->
qqrd2e
;
qqrd2e
=
force
->
qqrd2e
;
if
(
!
initialized
)
{
if
(
!
initialized
)
{
...
@@ -129,9 +137,7 @@ void Scafacos::compute(int eflag, int vflag)
...
@@ -129,9 +137,7 @@ void Scafacos::compute(int eflag, int vflag)
double
*
q
=
atom
->
q
;
double
*
q
=
atom
->
q
;
int
nlocal
=
atom
->
nlocal
;
int
nlocal
=
atom
->
nlocal
;
// RENE: why is scale needed?
const
double
qscale
=
qqrd2e
;
const
double
qscale
=
qqrd2e
*
scale
;
if
(
eflag
||
vflag
)
ev_setup
(
eflag
,
vflag
);
if
(
eflag
||
vflag
)
ev_setup
(
eflag
,
vflag
);
else
eflag_atom
=
0
;
else
eflag_atom
=
0
;
...
@@ -155,16 +161,6 @@ void Scafacos::compute(int eflag, int vflag)
...
@@ -155,16 +161,6 @@ void Scafacos::compute(int eflag, int vflag)
}
}
// initialize epot & efield
// RENE: is this necessary? or does Scafacos just set them
for
(
int
i
=
0
;
i
<
nlocal
;
i
++
)
{
epot
[
i
]
=
0.0
;
efield
[
i
][
0
]
=
efield
[
i
][
1
]
=
efield
[
i
][
2
]
=
0.0
;
}
// ScaFaCoS calculation of full Coulombics
result
=
fcs_run
(
fcs
,
nlocal
,
&
x
[
0
][
0
],
q
,
&
efield
[
0
][
0
],
epot
);
result
=
fcs_run
(
fcs
,
nlocal
,
&
x
[
0
][
0
],
q
,
&
efield
[
0
][
0
],
epot
);
check_result
(
result
);
check_result
(
result
);
...
@@ -196,7 +192,7 @@ void Scafacos::compute(int eflag, int vflag)
...
@@ -196,7 +192,7 @@ void Scafacos::compute(int eflag, int vflag)
int
Scafacos
::
modify_param
(
int
narg
,
char
**
arg
)
int
Scafacos
::
modify_param
(
int
narg
,
char
**
arg
)
{
{
//
RENE:
add any Scafacos options here you want to expose to LAMMPS
// add any Scafacos options here you want to expose to LAMMPS
// syntax: kspace_modify scafacos keyword value1 value2 ...
// syntax: kspace_modify scafacos keyword value1 value2 ...
// keyword = tolerance
// keyword = tolerance
// value1 = energy, energy_rel, etc
// value1 = energy, energy_rel, etc
...
@@ -245,17 +241,17 @@ void Scafacos::setup_handle()
...
@@ -245,17 +241,17 @@ void Scafacos::setup_handle()
{
{
// store simulation box params
// store simulation box params
// setup periodicity
old_periodicity
[
0
]
=
domain
->
xperiodic
;
old_periodicity
[
0
]
=
domain
->
xperiodic
;
old_periodicity
[
1
]
=
domain
->
yperiodic
;
old_periodicity
[
1
]
=
domain
->
yperiodic
;
old_periodicity
[
2
]
=
domain
->
zperiodic
;
old_periodicity
[
2
]
=
domain
->
zperiodic
;
// RENE: what does SCFCS mean by offset?
// setup box origin (lower left front corner of the system)
// it's an integer flag in LAMMPS, but being stored in a float?
old_origin
[
0
]
=
domain
->
boundary
[
0
][
0
];
old_origin
[
1
]
=
domain
->
boundary
[
1
][
0
];
old_offset
[
0
]
=
domain
->
boundary
[
0
][
0
];
old_origin
[
2
]
=
domain
->
boundary
[
2
][
0
];
old_offset
[
1
]
=
domain
->
boundary
[
1
][
0
];
old_offset
[
2
]
=
domain
->
boundary
[
2
][
0
];
// setup box vectors (base vectors of the system box)
old_box_x
[
0
]
=
domain
->
prd
[
0
];
old_box_x
[
0
]
=
domain
->
prd
[
0
];
old_box_x
[
1
]
=
old_box_x
[
2
]
=
0.0
;
old_box_x
[
1
]
=
old_box_x
[
2
]
=
0.0
;
old_box_y
[
1
]
=
domain
->
prd
[
1
];
old_box_y
[
1
]
=
domain
->
prd
[
1
];
...
@@ -263,10 +259,10 @@ void Scafacos::setup_handle()
...
@@ -263,10 +259,10 @@ void Scafacos::setup_handle()
old_box_z
[
2
]
=
domain
->
prd
[
2
];
old_box_z
[
2
]
=
domain
->
prd
[
2
];
old_box_z
[
1
]
=
old_box_z
[
0
]
=
0.0
;
old_box_z
[
1
]
=
old_box_z
[
0
]
=
0.0
;
// setup number of atoms in the system
old_natoms
=
atom
->
natoms
;
old_natoms
=
atom
->
natoms
;
// set all required ScaFaCoS params
// store parameters to ScaFaCoS handle
result
=
fcs_set_box_a
(
fcs
,
old_box_x
);
result
=
fcs_set_box_a
(
fcs
,
old_box_x
);
check_result
(
result
);
check_result
(
result
);
...
@@ -276,7 +272,7 @@ void Scafacos::setup_handle()
...
@@ -276,7 +272,7 @@ void Scafacos::setup_handle()
result
=
fcs_set_box_c
(
fcs
,
old_box_z
);
result
=
fcs_set_box_c
(
fcs
,
old_box_z
);
check_result
(
result
);
check_result
(
result
);
result
=
fcs_set_box_origin
(
fcs
,
old_o
ffset
);
result
=
fcs_set_box_origin
(
fcs
,
old_o
rigin
);
check_result
(
result
);
check_result
(
result
);
result
=
fcs_set_periodicity
(
fcs
,
old_periodicity
);
result
=
fcs_set_periodicity
(
fcs
,
old_periodicity
);
...
@@ -285,11 +281,12 @@ void Scafacos::setup_handle()
...
@@ -285,11 +281,12 @@ void Scafacos::setup_handle()
result
=
fcs_set_total_particles
(
fcs
,
old_natoms
);
result
=
fcs_set_total_particles
(
fcs
,
old_natoms
);
check_result
(
result
);
check_result
(
result
);
// RENE: disable short-range calculations within LAMMPS
// allow ScaFaCoS to calculate the near field computations for now
// not sure what this is doing
// TODO: allow the delegation of the near field computations
// is this the correct thing to do for now?
// within LAMMPS
// (near_field_flag = 1 -> enables the internal near field calcs
int
near_field_flag
=
0
;
// 0 -> disables the internal near field calcs
int
near_field_flag
=
1
;
result
=
fcs_set_near_field_flag
(
fcs
,
near_field_flag
);
result
=
fcs_set_near_field_flag
(
fcs
,
near_field_flag
);
check_result
(
result
);
check_result
(
result
);
}
}
...
@@ -307,9 +304,9 @@ bool Scafacos::box_has_changed()
...
@@ -307,9 +304,9 @@ bool Scafacos::box_has_changed()
(
periodicity
[
0
]
!=
old_periodicity
[
0
])
||
(
periodicity
[
0
]
!=
old_periodicity
[
0
])
||
(
periodicity
[
1
]
!=
old_periodicity
[
1
])
||
(
periodicity
[
1
]
!=
old_periodicity
[
1
])
||
(
periodicity
[
2
]
!=
old_periodicity
[
2
])
||
(
periodicity
[
2
]
!=
old_periodicity
[
2
])
||
(
domain
->
boundary
[
0
][
0
]
!=
old_o
ffset
[
0
])
||
(
domain
->
boundary
[
0
][
0
]
!=
old_o
rigin
[
0
])
||
(
domain
->
boundary
[
1
][
0
]
!=
old_o
ffset
[
1
])
||
(
domain
->
boundary
[
1
][
0
]
!=
old_o
rigin
[
1
])
||
(
domain
->
boundary
[
2
][
0
]
!=
old_o
ffset
[
2
])
||
(
domain
->
boundary
[
2
][
0
]
!=
old_o
rigin
[
2
])
||
(
prd
[
0
]
!=
old_box_x
[
0
])
||
(
prd
[
0
]
!=
old_box_x
[
0
])
||
(
prd
[
1
]
!=
old_box_y
[
1
])
||
(
prd
[
1
]
!=
old_box_y
[
1
])
||
(
prd
[
2
]
!=
old_box_z
[
2
])
||
(
prd
[
2
]
!=
old_box_z
[
2
])
||
...
@@ -333,9 +330,6 @@ void Scafacos::check_result(FCSResult result)
...
@@ -333,9 +330,6 @@ void Scafacos::check_result(FCSResult result)
std
::
string
err_msg
=
ss
.
str
();
std
::
string
err_msg
=
ss
.
str
();
const
char
*
str
=
err_msg
.
c_str
();
const
char
*
str
=
err_msg
.
c_str
();
// RENE: will all procs have same error?
// if so, then should call error->all(FLERR,str)
error
->
one
(
FLERR
,
str
);
error
->
one
(
FLERR
,
str
);
}
}
This diff is collapsed.
Click to expand it.
src/USER-SCAFACOS/scafacos.h
+
1
−
1
View file @
fba165d6
...
@@ -51,7 +51,7 @@ class Scafacos : public KSpace {
...
@@ -51,7 +51,7 @@ class Scafacos : public KSpace {
// so ScaFaCoS can detect if changes, e.g. for NPT
// so ScaFaCoS can detect if changes, e.g. for NPT
fcs_float
old_box_x
[
3
],
old_box_y
[
3
],
old_box_z
[
3
];
fcs_float
old_box_x
[
3
],
old_box_y
[
3
],
old_box_z
[
3
];
fcs_float
old_o
ffset
[
3
];
fcs_float
old_o
rigin
[
3
];
fcs_int
old_periodicity
[
3
];
fcs_int
old_periodicity
[
3
];
fcs_int
old_natoms
;
fcs_int
old_natoms
;
...
...
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