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 201 of file RGPotEngine.cpp.

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