53 influenceDistance_(8.1500),
54 cutoff_(influenceDistance_),
55 cutoffSq_(cutoff_ * cutoff_),
56 modelWillNotRequestNeighborsOfNoncontributingParticles_(1)
58 *error = ConvertUnits(modelCreate,
62 requestedTemperatureUnit,
70 1, &cutoff_, &modelWillNotRequestNeighborsOfNoncontributingParticles_);
86 reinterpret_cast<KIM::Function *>(CACreate))
91 reinterpret_cast<KIM::Function *>(compute))
96 reinterpret_cast<KIM::Function *>(CADestroy))
101 reinterpret_cast<KIM::Function *>(destroy));
132 #undef KIM_LOGGER_OBJECT_NAME 133 #define KIM_LOGGER_OBJECT_NAME modelCompute 139 int const * numberOfParticlesPointer;
148 double const epsilon = lj->epsilon_;
149 double const sigma = lj->sigma_;
150 double const cutoffSq = lj->cutoffSq_;
154 &numberOfParticlesPointer)
157 &particleSpeciesCodes)
160 &particleContributing)
163 (
double const **) &coordinates)
168 (
double const **) &partialForces);
171 LOG_ERROR(
"Unable to get argument pointers");
178 *partialEnergy = 0.0;
179 int const extent = numberOfParticles *
DIMENSION;
180 for (
int i = 0; i < extent; ++i) { partialForces[i] = 0.0; }
183 int i, j, jj, numberOfNeighbors;
184 int const * neighbors;
186 double xcoord, ycoord, zcoord;
187 double xrij, yrij, zrij;
189 double r2inv, r6inv, dphiByR, dEidrByR;
190 double xdf, ydf, zdf;
191 double const fortyEight = 48.0 * epsilon * pow(sigma, 12.0);
192 double const twentyFour = 24.0 * epsilon * pow(sigma, 6.0);
193 double const four12 = 4.0 * epsilon * pow(sigma, 12.0);
194 double const four6 = 4.0 * epsilon * pow(sigma, 6.0);
197 if (particleContributing[i])
199 xcoord = coordinates[i * DIMENSION + 0];
200 ycoord = coordinates[i * DIMENSION + 1];
201 zcoord = coordinates[i * DIMENSION + 2];
204 0, i, &numberOfNeighbors, &neighbors);
206 for (jj = 0; jj < numberOfNeighbors; ++jj)
209 jContributing = particleContributing[j];
211 if (!(jContributing && (j < i)))
213 xrij = coordinates[j * DIMENSION + 0] - xcoord;
214 yrij = coordinates[j * DIMENSION + 1] - ycoord;
215 zrij = coordinates[j * DIMENSION + 2] - zcoord;
217 rij2 = xrij * xrij + yrij * yrij + zrij * zrij;
222 r6inv = r2inv * r2inv * r2inv;
223 phi = 0.5 * r6inv * (four12 * r6inv - four6);
224 dphiByR = r6inv * (twentyFour - fortyEight * r6inv) * r2inv;
226 *partialEnergy += phi;
229 *partialEnergy += phi;
234 dEidrByR = 0.5 * dphiByR;
237 xdf = dEidrByR * xrij;
238 ydf = dEidrByR * yrij;
239 zdf = dEidrByR * zrij;
240 partialForces[i * DIMENSION + 0] += xdf;
241 partialForces[i * DIMENSION + 1] += ydf;
242 partialForces[i * DIMENSION + 2] += zdf;
243 partialForces[j * DIMENSION + 0] -= xdf;
244 partialForces[j * DIMENSION + 1] -= ydf;
245 partialForces[j * DIMENSION + 2] -= zdf;
292 double influenceDistance_;
295 int const modelWillNotRequestNeighborsOfNoncontributingParticles_;
298 #undef KIM_LOGGER_OBJECT_NAME 299 #define KIM_LOGGER_OBJECT_NAME modelCreate 318 double convertLength = 1.0;
327 requestedTemperatureUnit,
337 LOG_ERROR(
"Unable to convert length unit");
340 influenceDistance_ *= convertLength;
341 cutoff_ = influenceDistance_;
342 cutoffSq_ = cutoff_ * cutoff_;
343 sigma_ *= convertLength;
346 double convertEnergy = 1.0;
355 requestedTemperatureUnit,
365 LOG_ERROR(
"Unable to convert energy unit");
368 epsilon_ *= convertEnergy;
371 ier = modelCreate->
SetUnits(requestedLengthUnit,
378 LOG_ERROR(
"Unable to set units to requested values");
401 LennardJones_Ar *
const model =
new LennardJones_Ar(modelCreate,
405 requestedTemperatureUnit,
int ModelComputeArgumentsDestroyFunction(ModelCompute const *const modelCompute, ModelComputeArgumentsDestroy *const modelComputeArgumentsDestroy)
Prototype for MODEL_ROUTINE_NAME::ComputeArgumentsDestroy routine.
TemperatureUnit const unused
Indicates that a TemperatureUnit is not used.
An Extensible Enumeration for the TemperatureUnit's supported by the KIM API.
SpeciesName const Ar
The standard Argon species.
An Extensible Enumeration for the TimeUnit's supported by the KIM API.
int ModelDestroyFunction(ModelDestroy *const modelDestroy)
Prototype for MODEL_ROUTINE_NAME::Destroy routine.
int SetSpeciesCode(SpeciesName const speciesName, int const code)
Set integer code for supported SpeciesName.
int SetModelNumbering(Numbering const numbering)
Set the Model's particle Numbering.
recursive subroutine, public destroy(model_destroy_handle, ierr)
ComputeArgumentName const coordinates
The standard coordinates argument.
#define LOG_ERROR(message)
Convenience macro for ERROR Log entries with compile-time optimization.
ModelRoutineName const Destroy
The standard Destroy routine.
int SetUnits(LengthUnit const lengthUnit, EnergyUnit const energyUnit, ChargeUnit const chargeUnit, TemperatureUnit const temperatureUnit, TimeUnit const timeUnit)
Set the Model's base unit values.
ChargeUnit const unused
Indicates that a ChargeUnit is not used.
void GetModelBufferPointer(void **const ptr) const
Get the Model's buffer pointer within the Model object.
void SetInfluenceDistancePointer(double const *const influenceDistance)
Set the Model's influence distance data pointer.
int SetArgumentSupportStatus(ComputeArgumentName const computeArgumentName, SupportStatus const supportStatus)
Set the SupportStatus of a ComputeArgumentName.
int ModelComputeFunction(ModelCompute const *const modelCompute, ModelComputeArguments const *const modelComputeArgumentsCreate)
Prototype for MODEL_ROUTINE_NAME::Compute routine.
void SetModelBufferPointer(void *const ptr)
Set the Model's buffer pointer within the Model object.
SupportStatus const required
The standard required status.
An Extensible Enumeration for the LengthUnit's supported by the KIM API.
Provides the interface to a KIM API Model object for use by models within their MODEL_ROUTINE_NAME::D...
int GetArgumentPointer(ComputeArgumentName const computeArgumentName, int const **const ptr) const
Get the data pointer for a ComputeArgumentName.
int ModelComputeArgumentsCreateFunction(ModelCompute const *const modelCompute, ModelComputeArgumentsCreate *const modelComputeArgumentsCreate)
Prototype for MODEL_ROUTINE_NAME::ComputeArgumentsCreate routine.
ComputeArgumentName const particleContributing
The standard particleContributing argument.
ComputeArgumentName const partialEnergy
The standard partialEnergy argument.
Provides the interface to a KIM API Model object for use by models within their MODEL_ROUTINE_NAME::C...
ModelRoutineName const ComputeArgumentsCreate
The standard ComputeArgumentsCreate routine.
ModelRoutineName const ComputeArgumentsDestroy
The standard ComputeArgumentsDestroy routine.
Provides the interface to a KIM API ComputeArguments object for use by models within their MODEL_ROUT...
void SetNeighborListPointers(int const numberOfNeighborLists, double const *const cutoffs, int const *const modelWillNotRequestNeighborsOfNoncontributingParticles)
Set the Model's neighbor list data pointers.
An Extensible Enumeration for the EnergyUnit's supported by the KIM API.
LanguageName const cpp
The standard cpp language.
ModelRoutineName const Compute
The standard Compute routine.
LengthUnit const A
The standard angstrom unit of length.
Provides the interface to a KIM API ComputeArguments object for use by models within their MODEL_ROUT...
ComputeArgumentName const partialForces
The standard partialForces argument.
void GetModelBufferPointer(void **const ptr) const
Get the Model's buffer pointer within the Model object.
EnergyUnit const eV
The standard electronvolt unit of energy.
ComputeArgumentName const particleSpeciesCodes
The standard particleSpeciesCodes argument.
Provides the interface to a KIM API ComputeArguments object for use by models within their MODEL_ROUT...
An Extensible Enumeration for the ChargeUnit's supported by the KIM API.
ComputeArgumentName const numberOfParticles
The standard numberOfParticles argument.
int GetNeighborList(int const neighborListIndex, int const particleNumber, int *const numberOfNeighbors, int const **const neighborsOfParticle) const
Get the neighbor list for a particle of interest corresponding to a particular neighbor list cutoff d...
int model_create(KIM::ModelCreate *const modelCreate, KIM::LengthUnit const requestedLengthUnit, KIM::EnergyUnit const requestedEnergyUnit, KIM::ChargeUnit const requestedChargeUnit, KIM::TemperatureUnit const requestedTemperatureUnit, KIM::TimeUnit const requestedTimeUnit)
LennardJones_Ar(KIM::ModelCreate *const modelCreate, KIM::LengthUnit const requestedLengthUnit, KIM::EnergyUnit const requestedEnergyUnit, KIM::ChargeUnit const requestedChargeUnit, KIM::TemperatureUnit const requestedTemperatureUnit, KIM::TimeUnit const requestedTimeUnit, int *const error)
Provides the interface to a KIM API Model object for use by models within their MODEL_ROUTINE_NAME::C...
static int Destroy(KIM::ModelDestroy *const modelDestroy)
Numbering const zeroBased
The standard zeroBased numbering.
TimeUnit const unused
Indicates that a TimeUnit is not used.
static int ComputeArgumentsDestroy(KIM::ModelCompute const *const, KIM::ModelComputeArgumentsDestroy *const)
int SetRoutinePointer(ModelRoutineName const modelRoutineName, LanguageName const languageName, int const required, Function *const fptr)
Set the function pointer for the ModelRoutineName of interest.
LogVerbosity const error
The standard error verbosity.
static int Compute(KIM::ModelCompute const *const modelCompute, KIM::ModelComputeArguments const *const modelComputeArguments)
static int ConvertUnit(LengthUnit const fromLengthUnit, EnergyUnit const fromEnergyUnit, ChargeUnit const fromChargeUnit, TemperatureUnit const fromTemperatureUnit, TimeUnit const fromTimeUnit, LengthUnit const toLengthUnit, EnergyUnit const toEnergyUnit, ChargeUnit const toChargeUnit, TemperatureUnit const toTemperatureUnit, TimeUnit const toTimeUnit, double const lengthExponent, double const energyExponent, double const chargeExponent, double const temperatureExponent, double const timeExponent, double *const conversionFactor)
Get the multiplicative factor to convert between a derived unit represented in two different sets of ...
static int ComputeArgumentsCreate(KIM::ModelCompute const *const, KIM::ModelComputeArgumentsCreate *const modelComputeArgumentsCreate)