Loading...
Searching...
No Matches
eon Namespace Reference

Functions

::CPMDParams::Builder fillCpmdParams (::capnp::MallocMessageBuilder &msg, const RGPotEngineOptions &opt)

Function Documentation

◆ fillCpmdParams()

CPMDParams::Builder eon::fillCpmdParams ( ::capnp::MallocMessageBuilder & msg,
const RGPotEngineOptions & opt )

Definition at line 194 of file RGPotEngine.cpp.

195 {
196 ::CPMDParams::Builder params = msg.initRoot<::CPMDParams>();
197 if (!opt.params_path.empty()) {
198 const auto words = read_params_file(opt.params_path);
199 ::capnp::FlatArrayMessageReader reader(
200 kj::arrayPtr(words.data(), words.size()));
201 msg.setRoot(reader.getRoot<::CPMDParams>());
202 params = msg.getRoot<::CPMDParams>();
203 } else {
204 params.setFunctional(opt.functional);
205 params.setCutOffRy(opt.cutoff_ry);
206 params.setCharge(opt.charge);
207 params.setMultiplicity(opt.multiplicity);
208 if (!opt.title.empty())
209 params.setTitle(opt.title);
210 if (opt.memory_mb > 0)
211 params.setMemoryMb(static_cast<uint32_t>(opt.memory_mb));
212 }
213 if (!opt.engine_path.empty())
214 params.setEnginePath(opt.engine_path);
215 else if (!opt.engine_library.empty())
216 params.setEnginePath(opt.engine_library);
217 if (!opt.engine_root.empty())
218 params.setCpmdRoot(opt.engine_root);
219 if (!opt.scratch_dir.empty())
220 params.setScratchDir(opt.scratch_dir);
221 if (!opt.permanent_dir.empty())
222 params.setPermanentDir(opt.permanent_dir);
223
224 std::string block = opt.input_block;
225 if (block.empty()) {
226 if (const char *env = std::getenv("RGPOT_CPMD_INPUT_BLOCK"))
227 block = env;
228 }
229 if (!block.empty()) {
230 std::vector<std::string> kept;
231 {
232 auto existing = params.getInputBlocks();
233 kept.reserve(existing.size());
234 for (auto text : existing)
235 kept.emplace_back(text.cStr());
236 }
237 auto blocks = params.initInputBlocks(kept.size() + 1);
238 for (std::size_t i = 0; i < kept.size(); ++i)
239 blocks.set(i, kept[i]);
240 blocks.set(kept.size(), block);
241 }
242 return params;
243}
std::string title
Definition RGPotEngine.h:19
std::string scratch_dir
Definition RGPotEngine.h:21
std::string engine_path
Definition RGPotEngine.h:16
std::string params_path
Definition RGPotEngine.h:26
std::string engine_library
Definition RGPotEngine.h:17
std::string permanent_dir
Definition RGPotEngine.h:24
std::string functional
Definition RGPotEngine.h:12
std::string engine_root
Definition RGPotEngine.h:18
std::string input_block
Definition RGPotEngine.h:23