PSCF v1.4.0
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
38 // Protected constructor and destructor (see below)
39
42
51
55 int nParameter() const;
56
61
67 double parameter(int i) const;
68
75 bool isInitialized() const;
76
80
86 const RealVec<D>& rBasis(int i) const;
87
93 const RealVec<D>& kBasis(int i) const;
94
102 double drBasis(int k, int i, int j) const;
103
111 double dkBasis(int k, int i, int j) const;
112
120 double drrBasis(int k, int i, int j) const;
121
129 double dkkBasis(int k, int i, int j) const;
130
134
140 virtual double ksq(IntVec<D> const & k) const;
141
152 virtual double dksq(IntVec<D> const & vec, int n) const;
153
157
164
168 bool hasSignal() const;
169
174
176
177 protected:
178
179 // Protected member functions
180
184 UnitCellBase();
185
189 virtual ~UnitCellBase() = default;
190
202 void setLattice();
203
204 // Protected member variables
205
210
215
223
231
240
249
254
259
264
265 private:
266
270 Signal<void>* signalPtr_;
271
278 void initializeToZero();
279
287 virtual void setBasis() = 0;
288
292 void computeDerivatives();
293
297 UnitCellBase(UnitCellBase<D> const & other);
298
302 UnitCellBase<D>& operator = (UnitCellBase<D> const & other);
303
304 };
305
306 // Inline member functions
307
308 /*
309 * Get the number of Parameters in the unit cell.
310 */
311 template <int D>
312 inline
314 { return nParameter_; }
315
316 /*
317 * Get a single parameter of the unit cell.
318 */
319 template <int D>
320 inline
321 double UnitCellBase<D>::parameter(int i) const
322 { return parameters_[i]; }
323
324 /*
325 * Get Bravais basis vector i.
326 */
327 template <int D>
328 inline
330 { return rBasis_[i]; }
331
332 /*
333 * Get reciprocal basis vector i.
334 */
335 template <int D>
336 inline
338 { return kBasis_[i]; }
339
340 /*
341 * Get component j of derivative of r basis vector i w/respect to param k.
342 */
343 template <int D>
344 inline
345 double UnitCellBase<D>::drBasis(int k, int i, int j) const
346 { return drBasis_[k](i,j); }
347
348 /*
349 * Get component j of derivative of r basis vector i w/respect to param k.
350 */
351 template <int D>
352 inline
353 double UnitCellBase<D>::dkBasis(int k, int i, int j) const
354 { return dkBasis_[k](i, j); }
355
356 /*
357 * Get the derivative of ki*kj with respect to parameter k.
358 */
359 template <int D>
360 inline
361 double UnitCellBase<D>::dkkBasis(int k, int i, int j) const
362 { return dkkBasis_[k](i, j); }
363
364 /*
365 * Get the derivative of ri*rj with respect to parameter k.
366 */
367 template <int D>
368 inline
369 double UnitCellBase<D>::drrBasis(int k, int i, int j) const
370 { return drrBasis_[k](i, j); }
371
372 /*
373 * Is this unit cell initialized?
374 */
375 template <int D>
376 inline
378 { return isInitialized_; }
379
380 // Explicit instantiation declaration
381 extern template class UnitCellBase<1>;
382 extern template class UnitCellBase<2>;
383 extern template class UnitCellBase<3>;
384
385}
386}
387#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.
virtual ~UnitCellBase()=default
Destructor.
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 complex.cpp:11
PSCF package top-level namespace.
Utility classes for scientific computation.