MCPcopy Create free account
hub / github.com/CompPhysVienna/n2p2 / setCompactFunction

Method setCompactFunction

src/libnnp/SymFncBaseComp.cpp:39–92  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

37}
38
39void SymFncBaseComp::setCompactFunction(string subtype)
40{
41 if (subtype.size() < 1 || subtype.size() > 3)
42 {
43 throw runtime_error(strpr("ERROR: Invalid compact function type "
44 "specification: \"%s\".\n",
45 subtype.c_str()));
46 }
47
48 using CFT = CoreFunction::Type;
49 // Check for polynomials.
50 if (subtype.front() == 'p')
51 {
52 if (subtype.at(1) == '1') cr.setCoreFunction(CFT::POLY1);
53 else if (subtype.at(1) == '2') cr.setCoreFunction(CFT::POLY2);
54 else if (subtype.at(1) == '3') cr.setCoreFunction(CFT::POLY3);
55 else if (subtype.at(1) == '4') cr.setCoreFunction(CFT::POLY4);
56 else
57 {
58 throw runtime_error(strpr("ERROR: Invalid polynom type: \"%s\".\n",
59 subtype.c_str()));
60 }
61 if (subtype.size() == 3)
62 {
63 if (subtype.at(2) == 'a')
64 {
65#ifndef N2P2_NO_ASYM_POLY
66 asymmetric = true;
67 cr.setAsymmetric(true);
68#else
69 throw runtime_error("ERROR: Compiled without support for "
70 "asymmetric polynomial symmetry functions "
71 "(-DN2P2_NO_ASYM_POLY).\n");
72#endif
73 }
74 else
75 {
76 throw runtime_error(strpr("ERROR: Invalid polynom specifier: "
77 "\"%s\".\n", subtype.c_str()));
78 }
79 }
80 }
81 else if (subtype.front() == 'e')
82 {
83 cr.setCoreFunction(CFT::EXP);
84 }
85 else
86 {
87 throw runtime_error(strpr("ERROR: Unknown compact SF type: \"%s\".\n",
88 subtype.c_str()));
89 }
90
91 return;
92}
93
94SymFncBaseComp::SymFncBaseComp(size_t type,
95 ElementMap const& elementMap) :

Callers

nothing calls this directly

Calls 4

strprFunction · 0.85
sizeMethod · 0.80
setCoreFunctionMethod · 0.80
setAsymmetricMethod · 0.45

Tested by

no test coverage detected