76 int numberOfModelRoutineNames;
77 KIM::MODEL_ROUTINE_NAME::GetNumberOfModelRoutineNames(
78 &numberOfModelRoutineNames);
79 for (
int i = 0; i < numberOfModelRoutineNames; ++i)
81 KIM::ModelRoutineName modelRoutineName;
83 = KIM::MODEL_ROUTINE_NAME::GetModelRoutineName(i, &modelRoutineName);
84 if (error) {
MY_ERROR(
"Unable to get ModelRoutineName."); }
87 error =
kim_ptr->IsRoutinePresent(
88 modelRoutineName, &present, &required);
89 if (error) {
MY_ERROR(
"Unable to get routine present/required."); }
91 std::cout <<
"Model routine name \"" << modelRoutineName.ToString()
92 <<
"\" has present = " << present
93 <<
" and required = " << required <<
"." << std::endl;
95 if ((present ==
true) && (required ==
true))
97 using namespace KIM::MODEL_ROUTINE_NAME;
98 if (!((modelRoutineName == Create)
99 || (modelRoutineName == ComputeArgumentsCreate)
100 || (modelRoutineName == Compute) || (modelRoutineName == Refresh)
101 || (modelRoutineName == ComputeArgumentsDestroy)
102 || (modelRoutineName == Destroy)))
104 MY_ERROR(
"Unknown Routine \"" + modelRoutineName.ToString()
105 +
"\" is required by model.");
111 KIM::LengthUnit lengthUnit;
112 KIM::EnergyUnit energyUnit;
113 KIM::ChargeUnit chargeUnit;
114 KIM::TemperatureUnit temperatureUnit;
115 KIM::TimeUnit timeUnit;
118 &lengthUnit, &energyUnit, &chargeUnit, &temperatureUnit, &timeUnit);
120 std::cout <<
"LengthUnit is \"" << lengthUnit.ToString() <<
"\"" << std::endl
121 <<
"EnergyUnit is \"" << energyUnit.ToString() <<
"\"" << std::endl
122 <<
"ChargeUnit is \"" << chargeUnit.ToString() <<
"\"" << std::endl
123 <<
"TemperatureUnit is \"" << temperatureUnit.ToString() <<
"\""
125 <<
"TimeUnit is \"" << timeUnit.ToString() <<
"\"" << std::endl;
127 int number_of_neighbor_lists;
128 const double* cutoff_base;
131 int const * modelWillNotRequestNeighborsOfNoncontributingParticles;
132 kim_ptr->GetNeighborListPointers(&number_of_neighbor_lists,
134 &modelWillNotRequestNeighborsOfNoncontributingParticles);
135 std::cout <<
"Model has numberOfNeighborLists : " << number_of_neighbor_lists
137 for (
int i = 0; i < number_of_neighbor_lists; ++i)
140 <<
"Neighbor list " << i <<
" has cutoff "
143 "modelWillNotRequestNeighborsOfNoncontributingParticles "
144 << modelWillNotRequestNeighborsOfNoncontributingParticles[i]
151 int numberOfComputeArgumentNames;
152 KIM::COMPUTE_ARGUMENT_NAME::GetNumberOfComputeArgumentNames(
153 &numberOfComputeArgumentNames);
154 for (
int i = 0; i < numberOfComputeArgumentNames; ++i)
156 KIM::ComputeArgumentName computeArgumentName;
157 KIM::SupportStatus supportStatus;
158 KIM::COMPUTE_ARGUMENT_NAME::GetComputeArgumentName(i, &computeArgumentName);
159 KIM::DataType dataType;
160 KIM::COMPUTE_ARGUMENT_NAME::GetComputeArgumentDataType(computeArgumentName,
164 if (error)
MY_ERROR(
"unable to get ComputeArgument SupportStatus");
166 std::cout <<
"ComputeArgument Name \"" << computeArgumentName.ToString()
168 <<
" is of type \"" << dataType.ToString() <<
"\""
169 <<
" and has supportStatus \"" << supportStatus.ToString() <<
"\""
173 if (supportStatus == KIM::SUPPORT_STATUS::required)
175 if ((computeArgumentName != KIM::COMPUTE_ARGUMENT_NAME::partialEnergy)
176 && (computeArgumentName != KIM::COMPUTE_ARGUMENT_NAME::partialForces))
177 {
MY_ERROR(
"unsupported required ComputeArgument"); }
181 if ((computeArgumentName == KIM::COMPUTE_ARGUMENT_NAME::partialEnergy)
182 || (computeArgumentName == KIM::COMPUTE_ARGUMENT_NAME::partialForces))
184 if (!((supportStatus == KIM::SUPPORT_STATUS::required)
185 || (supportStatus == KIM::SUPPORT_STATUS::optional)))
186 {
MY_ERROR(
"energy or forces not available"); }
191 int numberOfComputeCallbackNames;
192 KIM::COMPUTE_CALLBACK_NAME::GetNumberOfComputeCallbackNames(
193 &numberOfComputeCallbackNames);
194 for (
int i = 0; i < numberOfComputeCallbackNames; ++i)
196 KIM::ComputeCallbackName computeCallbackName;
197 KIM::COMPUTE_CALLBACK_NAME::GetComputeCallbackName(i, &computeCallbackName);
198 KIM::SupportStatus supportStatus;
202 std::cout <<
"ComputeCallback Name \"" << computeCallbackName.ToString()
204 <<
" has supportStatus \"" << supportStatus.ToString() <<
"\""
208 if (supportStatus == KIM::SUPPORT_STATUS::required)
209 {
MY_ERROR(
"unsupported required ComputeCallback"); }
212 int numberOfParameters;
213 kim_ptr->GetNumberOfParameters(&numberOfParameters);
214 for (
int i = 0; i < numberOfParameters; ++i)
216 KIM::DataType dataType;
217 std::string
const * strName;
218 std::string
const * strDesc;
221 i, &dataType, &extent, &strName, &strDesc);
222 std::cout <<
"Parameter No. " << i <<
" has" << std::endl
223 <<
" data type : \"" << dataType.ToString() <<
"\"" << std::endl
224 <<
" extent : " << extent << std::endl
225 <<
" name : " << *strName << std::endl
226 <<
" description : " << *strDesc << std::endl;
231 error =
kim_ptr->IsRoutinePresent(
232 KIM::MODEL_ROUTINE_NAME::Extension, &present, NULL);
233 if (error) {
MY_ERROR(
"Unable to get Extension present/required."); }
236 KIM::SupportedExtensions supportedExtensions;
237 error =
kim_ptr->Extension(KIM_SUPPORTED_EXTENSIONS_ID,
238 &supportedExtensions);
239 if (error) {
MY_ERROR(
"Error returned from KIM::Model::Extension()."); }
240 std::cout <<
"Model Supports "
241 << supportedExtensions.numberOfSupportedExtensions
242 <<
" Extensions:" << std::endl;
243 for (
int i = 0; i < supportedExtensions.numberOfSupportedExtensions; ++i)
245 std::cout <<
" spportedExtensionID[" << std::setw(2) << i <<
"] = \""
246 << supportedExtensions.supportedExtensionID[i] <<
"\" "
247 <<
"which has required = "
248 << supportedExtensions.supportedExtensionRequired[i] <<
"."
255 const VectorXi& particleContributing,
258 KIM::Function* get_neigh_ptr,
260 KIM::Function* processDEDr_ptr)
265 int isSpeciesSupported;
268 KIM::SpeciesName speciesNameObject(config_ptr->
species[i]);
269 error =
kim_ptr->GetSpeciesSupportAndCode(speciesNameObject, &isSpeciesSupported,
speciesCode.data()+i);
270 if ((error) || (!isSpeciesSupported))
271 {
MY_ERROR(
"Species " + config_ptr->
species[i] +
" of particle " + std::to_string(i+1) +
" not supported"); }
279 computeArguments->SetArgumentPointer(KIM::COMPUTE_ARGUMENT_NAME::particleContributing,particleContributing.data())
283 (forces_ptr ==
nullptr ?
284 computeArguments->SetArgumentPointer(KIM::COMPUTE_ARGUMENT_NAME::partialForces,
static_cast<double*
>(
nullptr)) :
285 computeArguments->SetArgumentPointer(KIM::COMPUTE_ARGUMENT_NAME::partialForces, (*forces_ptr).data())
288 if (error)
MY_ERROR(
"KIM_API_set_data");
289 error =
computeArguments->SetCallbackPointer(KIM::COMPUTE_CALLBACK_NAME::GetNeighborList,
290 KIM::LANGUAGE_NAME::cpp, get_neigh_ptr, nl_ptr)
293 (processDEDr_ptr==
nullptr ?
294 computeArguments->SetCallbackPointer(KIM::COMPUTE_CALLBACK_NAME::ProcessDEDrTerm,
295 KIM::LANGUAGE_NAME::cpp,
nullptr,
nullptr) :
296 computeArguments->SetCallbackPointer(KIM::COMPUTE_CALLBACK_NAME::ProcessDEDrTerm,
297 KIM::LANGUAGE_NAME::cpp, processDEDr_ptr, bonds));
299 if (error)
throw(std::runtime_error(
"set_call_back"));