kim-api 2.3.0+AppleClang.AppleClang.GNU
An Application Programming Interface (API) for the Knowledgebase of Interatomic Models (KIM).
Loading...
Searching...
No Matches
LennardJones612.cpp
Go to the documentation of this file.
1//
2// KIM-API: An API for interatomic models
3// Copyright (c) 2013--2022, Regents of the University of Minnesota.
4// All rights reserved.
5//
6// Contributors:
7// Ryan S. Elliott
8// Andrew Akerson
9//
10// SPDX-License-Identifier: LGPL-2.1-or-later
11//
12// This library is free software; you can redistribute it and/or
13// modify it under the terms of the GNU Lesser General Public
14// License as published by the Free Software Foundation; either
15// version 2.1 of the License, or (at your option) any later version.
16//
17// This library is distributed in the hope that it will be useful,
18// but WITHOUT ANY WARRANTY; without even the implied warranty of
19// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20// Lesser General Public License for more details.
21//
22// You should have received a copy of the GNU Lesser General Public License
23// along with this library; if not, write to the Free Software Foundation,
24// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25//
26
27
28#include "LennardJones612.hpp"
30#include <cstddef>
31
32
33//==============================================================================
34//
35// This is the standard interface to KIM Model Drivers
36//
37//==============================================================================
38
39//******************************************************************************
40extern "C" {
41int model_driver_create(KIM::ModelDriverCreate * const modelDriverCreate,
42 KIM::LengthUnit const requestedLengthUnit,
43 KIM::EnergyUnit const requestedEnergyUnit,
44 KIM::ChargeUnit const requestedChargeUnit,
45 KIM::TemperatureUnit const requestedTemperatureUnit,
46 KIM::TimeUnit const requestedTimeUnit)
47{
48 int ier;
49
50 // read input files, convert units if needed, compute
51 // interpolation coefficients, set cutoff, and publish parameters
52 LennardJones612 * const modelObject
53 = new LennardJones612(modelDriverCreate,
54 requestedLengthUnit,
55 requestedEnergyUnit,
56 requestedChargeUnit,
57 requestedTemperatureUnit,
58 requestedTimeUnit,
59 &ier);
60 if (ier)
61 {
62 // constructor already reported the error
63 delete modelObject;
64 return ier;
65 }
66
67 // register pointer to LennardJones612 object in KIM object
68 modelDriverCreate->SetModelBufferPointer(static_cast<void *>(modelObject));
69
70 // everything is good
71 ier = false;
72 return ier;
73}
74} // extern "C"
75
76//==============================================================================
77//
78// Implementation of LennardJones612 public wrapper functions
79//
80//==============================================================================
81
82//******************************************************************************
84 KIM::ModelDriverCreate * const modelDriverCreate,
85 KIM::LengthUnit const requestedLengthUnit,
86 KIM::EnergyUnit const requestedEnergyUnit,
87 KIM::ChargeUnit const requestedChargeUnit,
88 KIM::TemperatureUnit const requestedTemperatureUnit,
89 KIM::TimeUnit const requestedTimeUnit,
90 int * const ier)
91{
92 implementation_ = new LennardJones612Implementation(modelDriverCreate,
93 requestedLengthUnit,
94 requestedEnergyUnit,
95 requestedChargeUnit,
96 requestedTemperatureUnit,
97 requestedTimeUnit,
98 ier);
99}
100
101//******************************************************************************
102LennardJones612::~LennardJones612() { delete implementation_; }
103
104//******************************************************************************
105// static member function
107{
108 LennardJones612 * modelObject;
109 modelDestroy->GetModelBufferPointer(reinterpret_cast<void **>(&modelObject));
110
111 if (modelObject != NULL)
112 {
113 // delete object itself
114 delete modelObject;
115 }
116
117 // everything is good
118 return false;
119}
120
121//******************************************************************************
122// static member function
124{
125 LennardJones612 * modelObject;
126 modelRefresh->GetModelBufferPointer(reinterpret_cast<void **>(&modelObject));
127
128 return modelObject->implementation_->Refresh(modelRefresh);
129}
130
131//******************************************************************************
132// static member function
134 KIM::ModelCompute const * const modelCompute,
135 KIM::ModelComputeArguments const * const modelComputeArguments)
136{
137 LennardJones612 * modelObject;
138 modelCompute->GetModelBufferPointer(reinterpret_cast<void **>(&modelObject));
139
140 return modelObject->implementation_->Compute(modelCompute,
141 modelComputeArguments);
142}
143
144//******************************************************************************
145// static member function
147 KIM::ModelCompute const * const modelCompute,
148 KIM::ModelComputeArgumentsCreate * const modelComputeArgumentsCreate)
149{
150 LennardJones612 * modelObject;
151 modelCompute->GetModelBufferPointer(reinterpret_cast<void **>(&modelObject));
152
153 return modelObject->implementation_->ComputeArgumentsCreate(
154 modelComputeArgumentsCreate);
155}
156
157//******************************************************************************
158// static member function
160 KIM::ModelCompute const * const modelCompute,
161 KIM::ModelComputeArgumentsDestroy * const modelComputeArgumentsDestroy)
162{
163 LennardJones612 * modelObject;
164 modelCompute->GetModelBufferPointer(reinterpret_cast<void **>(&modelObject));
165
166 return modelObject->implementation_->ComputeArgumentsDestroy(
167 modelComputeArgumentsDestroy);
168}
int model_driver_create(KIM::ModelDriverCreate *const modelDriverCreate, KIM::LengthUnit const requestedLengthUnit, KIM::EnergyUnit const requestedEnergyUnit, KIM::ChargeUnit const requestedChargeUnit, KIM::TemperatureUnit const requestedTemperatureUnit, KIM::TimeUnit const requestedTimeUnit)
An Extensible Enumeration for the ChargeUnit's supported by the KIM API.
An Extensible Enumeration for the EnergyUnit's supported by the KIM API.
An Extensible Enumeration for the LengthUnit's supported by the KIM API.
Provides the interface to a KIM API ComputeArguments object for use by models within their MODEL_ROUT...
Provides the interface to a KIM API ComputeArguments object for use by models within their MODEL_ROUT...
Provides the interface to a KIM API ComputeArguments object for use by models within their MODEL_ROUT...
Provides the interface to a KIM API Model object for use by models within their MODEL_ROUTINE_NAME::C...
void GetModelBufferPointer(void **const ptr) const
Get the Model's buffer pointer within the Model object.
Provides the interface to a KIM API Model object for use by models within their MODEL_ROUTINE_NAME::D...
void GetModelBufferPointer(void **const ptr) const
Get the Model's buffer pointer within the Model object.
Provides the interface to a KIM API Model object for use by models within their MODEL_ROUTINE_NAME::C...
void SetModelBufferPointer(void *const ptr)
Set the Model's buffer pointer within the Model object.
Provides the interface to a KIM API Model object for use by models within their MODEL_ROUTINE_NAME::R...
void GetModelBufferPointer(void **const ptr) const
Get the Model's buffer pointer within the Model object.
An Extensible Enumeration for the TemperatureUnit's supported by the KIM API.
An Extensible Enumeration for the TimeUnit's supported by the KIM API.
static int ComputeArgumentsCreate(KIM::ModelCompute const *const modelCompute, KIM::ModelComputeArgumentsCreate *const modelComputeArgumentsCreate)
static int Destroy(KIM::ModelDestroy *const modelDestroy)
static int Refresh(KIM::ModelRefresh *const modelRefresh)
LennardJones612(KIM::ModelDriverCreate *const modelDriverCreate, KIM::LengthUnit const requestedLengthUnit, KIM::EnergyUnit const requestedEnergyUnit, KIM::ChargeUnit const requestedChargeUnit, KIM::TemperatureUnit const requestedTemperatureUnit, KIM::TimeUnit const requestedTimeUnit, int *const ier)
static int Compute(KIM::ModelCompute const *const modelCompute, KIM::ModelComputeArguments const *const modelComputeArguments)
static int ComputeArgumentsDestroy(KIM::ModelCompute const *const modelCompute, KIM::ModelComputeArgumentsDestroy *const modelComputeArgumentsDestroy)
int Refresh(KIM::ModelRefresh *const modelRefresh)
int ComputeArgumentsCreate(KIM::ModelComputeArgumentsCreate *const modelComputeArgumentsCreate) const
int Compute(KIM::ModelCompute const *const modelCompute, KIM::ModelComputeArguments const *const modelComputeArguments)
int ComputeArgumentsDestroy(KIM::ModelComputeArgumentsDestroy *const modelComputeArgumentsDestroy) const