Skip to content
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
22 changes: 14 additions & 8 deletions examples/Argon/Argon.cpp
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
// Copyright 2024 Sebastian Eibl
//
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//
// https://www.apache.org/licenses/LICENSE-2.0
//
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include <format>

#include <CLI/App.hpp>
#include <CLI/Config.hpp>
#include <CLI/Formatter.hpp>
#include <Kokkos_Core.hpp>
#include <algorithm>
#include <format>
#include <fstream>
#include <iomanip>
#include <iostream>
Expand Down Expand Up @@ -72,7 +71,7 @@ struct Config

idx_t estimatedMaxNeighbors = 60;

const std::string resName = "Argon";
const std::string resName = "Argon";
const std::vector<std::string> typeNames = {"Ar"};
};

Expand Down Expand Up @@ -118,12 +117,19 @@ void LJ(Config& config)
{
auto subdomain =
data::Subdomain({0_r, 0_r, 0_r}, {config.Lx, config.Lx, config.Lx}, config.neighborCutoff);
const auto volume = subdomain.diameter[0] * subdomain.diameter[1] * subdomain.diameter[2];
const auto volume = subdomain.getVolume();
auto atoms = fillDomainWithAtomsSC(subdomain, config.numAtoms, 1_r);
auto rho = real_c(atoms.numLocalAtoms) / volume;
std::cout << "rho: " << rho << std::endl;

io::dumpGRO("atoms_initial.gro", atoms, subdomain, 0_r, "Argon", config.resName, config.typeNames, false);
io::dumpGRO("atoms_initial.gro",
atoms,
subdomain,
0_r,
"Argon",
config.resName,
config.typeNames,
false);

communication::GhostLayer ghostLayer;
action::LennardJones LJ(config.rc, config.sigma, config.epsilon, 0.7_r * config.sigma);
Expand Down
25 changes: 15 additions & 10 deletions examples/Argon/MultiResArgon.cpp
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
// Copyright 2024 Sebastian Eibl
//
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//
// https://www.apache.org/licenses/LICENSE-2.0
//
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include <format>

#include <CLI/App.hpp>
#include <CLI/Config.hpp>
#include <CLI/Formatter.hpp>
#include <Kokkos_Core.hpp>
#include <algorithm>
#include <format>
#include <fstream>
#include <iomanip>
#include <iostream>
Expand Down Expand Up @@ -76,9 +75,8 @@ struct Config

idx_t estimatedMaxNeighbors = 60;

const std::string resName = "Argon";
const std::string resName = "Argon";
const std::vector<std::string> typeNames = {"Ar"};

};

data::Atoms fillDomainWithAtomsSC(const data::Subdomain& subdomain,
Expand Down Expand Up @@ -125,13 +123,20 @@ void LJ(Config& config)
{
auto subdomain =
data::Subdomain({0_r, 0_r, 0_r}, {config.Lx, config.Lx, config.Lx}, config.neighborCutoff);
const auto volume = subdomain.diameter[0] * subdomain.diameter[1] * subdomain.diameter[2];
const auto volume = subdomain.getVolume();
auto atoms = fillDomainWithAtomsSC(subdomain, config.numAtoms, 1_r);
auto molecules = data::createMoleculeForEachAtom(atoms);
auto rho = real_c(atoms.numLocalAtoms) / volume;
std::cout << "rho: " << rho << std::endl;

io::dumpGRO("atoms_initial.gro", atoms, subdomain, 0_r, "Argon", config.resName, config.typeNames, false);
io::dumpGRO("atoms_initial.gro",
atoms,
subdomain,
0_r,
"Argon",
config.resName,
config.typeNames,
false);

communication::MultiResGhostLayer ghostLayer;
weighting_function::Slab weightingFunction({-100_r, -100_r, -100_r}, 1_r, 1_r, 1);
Expand Down Expand Up @@ -230,7 +235,7 @@ void LJ(Config& config)
subdomain,
step * config.dt,
"Argon",
config.resName,
config.resName,
config.typeNames,
false);

Expand Down
13 changes: 6 additions & 7 deletions examples/BinaryLennardJones/NPT.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// Copyright 2024 Sebastian Eibl
//
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//
// https://www.apache.org/licenses/LICENSE-2.0
//
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand All @@ -14,9 +14,8 @@

#include "NPT.hpp"

#include <format>

#include <algorithm>
#include <format>

#include "action/BerendsenBarostat.hpp"
#include "action/BerendsenThermostat.hpp"
Expand All @@ -38,7 +37,7 @@ void npt(YAML::Node& config, data::Atoms& atoms, data::Subdomain& subdomain)
auto rcVec = config["LJ"]["cutoff"].as<std::vector<real_t>>();
const real_t rc = std::ranges::max(rcVec);
const real_t neighborCutoff = rc + skin;
auto volume = subdomain.diameter[0] * subdomain.diameter[1] * subdomain.diameter[2];
auto volume = subdomain.getVolume();

communication::GhostLayer ghostLayer;
auto LJ = action::LennardJones(config["LJ"]["capping"].as<std::vector<real_t>>(),
Expand Down Expand Up @@ -79,7 +78,7 @@ void npt(YAML::Node& config, data::Atoms& atoms, data::Subdomain& subdomain)
false,
true,
false);
volume = subdomain.diameter[0] * subdomain.diameter[1] * subdomain.diameter[2];
volume = subdomain.getVolume();
maxAtomDisplacement = std::numeric_limits<real_t>::max();
}

Expand Down
11 changes: 5 additions & 6 deletions examples/BinaryLennardJones/NVT.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// Copyright 2024 Sebastian Eibl
//
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//
// https://www.apache.org/licenses/LICENSE-2.0
//
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand All @@ -14,9 +14,8 @@

#include "NVT.hpp"

#include <format>

#include <algorithm>
#include <format>

#include "action/BerendsenThermostat.hpp"
#include "action/LennardJones.hpp"
Expand All @@ -37,7 +36,7 @@ void nvt(YAML::Node& config, data::Atoms& atoms, const data::Subdomain& subdomai
auto rcVec = config["LJ"]["cutoff"].as<std::vector<real_t>>();
const real_t rc = std::ranges::max(rcVec);
const real_t neighborCutoff = rc + skin;
auto volume = subdomain.diameter[0] * subdomain.diameter[1] * subdomain.diameter[2];
auto volume = subdomain.getVolume();

communication::GhostLayer ghostLayer;
auto LJ = action::LennardJones(config["LJ"]["capping"].as<std::vector<real_t>>(),
Expand Down
5 changes: 2 additions & 3 deletions examples/BinaryLennardJones/SPARTIAN.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@

#include "SPARTIAN.hpp"

#include <format>

#include <algorithm>
#include <format>
#include <fstream>

#include "action/ContributeMoleculeForceToAtoms.hpp"
Expand Down Expand Up @@ -47,7 +46,7 @@ void spartian(YAML::Node& config,
auto rcVec = config["LJ"]["cutoff"].as<std::vector<real_t>>();
const real_t rc = std::ranges::max(rcVec);
const real_t neighborCutoff = rc + skin;
auto volume = subdomain.diameter[0] * subdomain.diameter[1] * subdomain.diameter[2];
auto volume = subdomain.getVolume();

communication::MultiResGhostLayer ghostLayer;
auto LJ = action::LJ_IdealGas(config["LJ"]["capping"].as<std::vector<real_t>>(),
Expand Down
22 changes: 14 additions & 8 deletions examples/DensityFluctuations/DensityFluctuations.cpp
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
// Copyright 2024 Sebastian Eibl
//
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//
// https://www.apache.org/licenses/LICENSE-2.0
//
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include <format>

#include <CLI/App.hpp>
#include <CLI/Config.hpp>
#include <CLI/Formatter.hpp>
#include <Kokkos_Core.hpp>
#include <format>
#include <fstream>
#include <iomanip>
#include <iostream>
Expand Down Expand Up @@ -86,7 +85,7 @@ struct Config
// thermodynamic force parameters
real_t thermodynamicForceModulation = 2.0_r;

const std::string resName = "Argon";
const std::string resName = "Argon";
const std::vector<std::string> typeNames = {"Ar"};
};

Expand Down Expand Up @@ -133,12 +132,19 @@ void LJ(Config& config)
auto subdomain = data::Subdomain({-config.Lx, -config.Ly, -config.Lz},
{config.Lx, config.Ly, config.Lz},
config.neighborCutoff);
const auto volume = subdomain.diameter[0] * subdomain.diameter[1] * subdomain.diameter[2];
const auto volume = subdomain.getVolume();
auto atoms = fillDomainWithAtomsSC(subdomain, config.numAtoms, 1_r);
auto rho = real_c(atoms.numLocalAtoms) / volume;
std::cout << "rho: " << rho << std::endl;

io::dumpGRO("atoms_initial.gro", atoms, subdomain, 0_r, "Argon", config.resName, config.typeNames, false);
io::dumpGRO("atoms_initial.gro",
atoms,
subdomain,
0_r,
"Argon",
config.resName,
config.typeNames,
false);

communication::GhostLayer ghostLayer;
action::LennardJones LJ(config.rc, config.sigma, config.epsilon, 0.7_r * config.sigma);
Expand Down
8 changes: 4 additions & 4 deletions examples/LennardJones/LennardJones.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// Copyright 2024 Sebastian Eibl
//
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//
// https://www.apache.org/licenses/LICENSE-2.0
//
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand Down Expand Up @@ -101,7 +101,7 @@ void LJ(Config& config)
{
auto subdomain =
data::Subdomain({0_r, 0_r, 0_r}, {config.Lx, config.Lx, config.Lx}, config.neighborCutoff);
const auto volume = subdomain.diameter[0] * subdomain.diameter[1] * subdomain.diameter[2];
const auto volume = subdomain.getVolume();
data::Atoms atoms(0);

if (!config.filename.empty())
Expand Down
39 changes: 19 additions & 20 deletions examples/SPC/SPC.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// Copyright 2024 Sebastian Eibl
//
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//
// https://www.apache.org/licenses/LICENSE-2.0
//
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand All @@ -14,12 +14,11 @@

#include "action/SPC.hpp"

#include <format>

#include <CLI/App.hpp>
#include <CLI/Config.hpp>
#include <CLI/Formatter.hpp>
#include <Kokkos_Core.hpp>
#include <format>
#include <fstream>
#include <iomanip>
#include <iostream>
Expand Down Expand Up @@ -191,7 +190,7 @@ void initMolecules(data::Molecules& molecules,
void SPC(Config& config)
{
auto subdomain = data::Subdomain({0_r, 0_r, 0_r}, {5_r, 5_r, 5_r}, config.neighborCutoff);
const auto volume = subdomain.diameter[0] * subdomain.diameter[1] * subdomain.diameter[2];
const auto volume = subdomain.getVolume();

data::Atoms atoms(0);
data::Molecules molecules(0);
Expand Down Expand Up @@ -363,25 +362,25 @@ void SPC(Config& config)
if (config.bOutput && (step > config.nsteps - 5000) && (step % 100 == 0))
{
io::dumpCSV(std::format("spc_{:0>6}.csv", step), atoms, false);
//io::dumpGRO(std::format("spc_{:0>6}.gro", step),
// atoms,
// subdomain,
// step * config.dt,
// "SPC water",
// false,
// true);
// io::dumpGRO(std::format("spc_{:0>6}.gro", step),
// atoms,
// subdomain,
// step * config.dt,
// "SPC water",
// false,
// true);
}

if (config.bOutput && (step > config.nsteps - 500) && (step % 10 == 0))
{
io::dumpCSV(std::format("spc_{:0>6}.csv", step), atoms, false);
//io::dumpGRO(std::format("spc_{:0>6}.gro", step),
// atoms,
// subdomain,
// step * config.dt,
// "SPC water",
// false,
// true);
// io::dumpGRO(std::format("spc_{:0>6}.gro", step),
// atoms,
// subdomain,
// step * config.dt,
// "SPC water",
// false,
// true);
}

if (step == 2000) config.thermostatInterval = 2000;
Expand Down
Loading