PSCF v1.3
UnitCellBase.h
1#ifndef PRDC_UNIT_CELL_BASE_H
2#define PRDC_UNIT_CELL_BASE_H
3
4/*
5* PSCF - Polymer Self-Consistent Field
6*
7* Copyright 2015 - 2025, The Regents of the University of Minnesota
8* Distributed under the terms of the GNU General Public License.
9*/
10
11#include <pscf/math/RealVec.h> // member
12#include <pscf/math/IntVec.h> // interface, with default parameters
13#include <util/containers/FArray.h> // member
14#include <util/containers/FMatrix.h> // member
15#include <util/containers/FSArray.h> // interface
16
17// Forward declarations
18namespace Util {
19 template <typename T> class Signal;
20 template <> class Signal<void>;
21}
22
23namespace Pscf {
24namespace Prdc {
25
26 using namespace Util;
27
33 template <int D>
35 {
36 public:
37
42
47
50
59
63 int nParameter() const;
64
69
75 double parameter(int i) const;
76
83 bool isInitialized() const;
84
88
94 const RealVec<D>& rBasis(int i) const;
95
101 const RealVec<D>& kBasis(int i) const;
102
110 double drBasis(int k, int i, int j) const;
111
119 double dkBasis(int k, int i, int j) const;
120
128 double drrBasis(int k, int i, int j) const;
129
137 double dkkBasis(int k, int i, int j) const;
138
142
148 virtual double ksq(IntVec<D> const & k) const;
149
160 virtual double dksq(IntVec<D> const & vec, int n) const;
161
165
172
176 bool hasSignal() const;
177
182
184
185 protected:
186
191
196
204
212
221
230
235
240
245
257 void setLattice();
258
259 private:
260
264 Signal<void>* signalPtr_;
265
272 void initializeToZero();
273
281 virtual void setBasis() = 0;
282
286 void computeDerivatives();
287
291 UnitCellBase(UnitCellBase<D> const & other);
292
296 UnitCellBase<D>& operator = (UnitCellBase<D> const & other);
297
298 };
299
300 // Inline member functions
301
302 /*
303 * Get the number of Parameters in the unit cell.
304 */
305 template <int D>
306 inline
308 { return nParameter_; }
309
310 /*
311 * Get a single parameter of the unit cell.
312 */
313 template <int D>
314 inline
315 double UnitCellBase<D>::parameter(int i) const
316 { return parameters_[i]; }
317
318 /*
319 * Get Bravais basis vector i.
320 */
321 template <int D>
322 inline
324 { return rBasis_[i]; }
325
326 /*
327 * Get reciprocal basis vector i.
328 */
329 template <int D>
330 inline
332 { return kBasis_[i]; }
333
334 /*
335 * Get component j of derivative of r basis vector i w/respect to param k.
336 */
337 template <int D>
338 inline
339 double UnitCellBase<D>::drBasis(int k, int i, int j) const
340 { return drBasis_[k](i,j); }
341
342 /*
343 * Get component j of derivative of r basis vector i w/respect to param k.
344 */
345 template <int D>
346 inline
347 double UnitCellBase<D>::dkBasis(int k, int i, int j) const
348 { return dkBasis_[k](i, j); }
349
350 /*
351 * Get the derivative of ki*kj with respect to parameter k.
352 */
353 template <int D>
354 inline
355 double UnitCellBase<D>::dkkBasis(int k, int i, int j) const
356 { return dkkBasis_[k](i, j); }
357
358 /*
359 * Get the derivative of ri*rj with respect to parameter k.
360 */
361 template <int D>
362 inline
363 double UnitCellBase<D>::drrBasis(int k, int i, int j) const
364 { return drrBasis_[k](i, j); }
365
366 /*
367 * Is this unit cell initialized?
368 */
369 template <int D>
370 inline
372 { return isInitialized_; }
373
374 #ifndef PRDC_UNIT_CELL_BASE_TPP
375 // Suppress implicit instantiation of base class
376 extern template class UnitCellBase<1>;
377 extern template class UnitCellBase<2>;
378 extern template class UnitCellBase<3>;
379 #endif
380
381}
382}
383#endif
An IntVec<D, T> is a D-component vector of elements of integer type T.
Definition IntVec.h:27
Base class template for a crystallographic unit cell.
bool isInitialized() const
Has this unit cell been initialized?
bool isInitialized_
Has this unit cell been fully initialized?
const RealVec< D > & rBasis(int i) const
Get Bravais basis vector i, denoted by a_i.
void setParameters(FSArray< double, 6 > const &parameters)
Set all the parameters of unit cell.
void setSignal(Signal< void > &signal)
Associating an externally defined signal with this unit cell.
const RealVec< D > & kBasis(int i) const
Get reciprocal basis vector i, denoted by b_i.
double drrBasis(int k, int i, int j) const
Get derivative of dot product ai.aj with respect to parameter k.
FArray< RealVec< D >, D > rBasis_
Array of Bravais lattice basis vectors.
FArray< FMatrix< double, D, D >, 6 > drBasis_
Array of derivatives of rBasis.
double dkkBasis(int k, int i, int j) const
Get derivative of dot product bi.bj with respect to parameter k.
FArray< RealVec< D >, D > kBasis_
Array of reciprocal lattice basis vectors.
FSArray< double, 6 > parameters() const
Get the parameters of this unit cell.
double drBasis(int k, int i, int j) const
Get component j of derivative of rBasis vector a_i w/respect to k.
FArray< double, 6 > parameters_
Parameters used to describe the unit cell.
virtual double ksq(IntVec< D > const &k) const
Compute square magnitude of reciprocal lattice vector.
FArray< FMatrix< double, D, D >, 6 > dkBasis_
Array of derivatives of kBasis.
FArray< FMatrix< double, D, D >, 6 > drrBasis_
Array of derivatives of a_i.a_j.
bool hasSignal() const
Does this object have an associated Signal<void>?
double dkBasis(int k, int i, int j) const
Get component j of derivative of kBasis vector b_i w/respect to k.
void setLattice()
Compute all protected data, given latticeSystem and parameters.
virtual double dksq(IntVec< D > const &vec, int n) const
Compute derivative of square wavevector w/respect to cell parameter.
int nParameter_
Number of parameters required to specify unit cell.
double parameter(int i) const
Get a single parameter of this unit cell.
FArray< FMatrix< double, D, D >, 6 > dkkBasis_
Array of derivatives of b_i.b_j.
int nParameter() const
Get the number of parameters in the unit cell.
A RealVec<D, T> is D-component vector with elements of floating type T.
Definition RealVec.h:28
A fixed size (static) contiguous array template.
Definition FArray.h:47
A fixed capacity (static) contiguous array with a variable logical size.
Definition FSArray.h:38
Notifier (or subject) in the Observer design pattern.
Definition Signal.h:39
Periodic fields and crystallography.
Definition CField.cpp:11
PSCF package top-level namespace.
Definition param_pc.dox:1
Utility classes for scientific computation.