OpenMD 3.2
Molecular Dynamics in the Open
Loading...
Searching...
No Matches
SFGTimeAvg.hpp
1/*
2 * Copyright (c) 2004-present, The University of Notre Dame. All rights
3 * reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
14 *
15 * 3. Neither the name of the copyright holder nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 *
31 * SUPPORT OPEN SCIENCE! If you use OpenMD or its source code in your
32 * research, please cite the following paper when you publish your work:
33 *
34 * [1] Drisko et al., J. Open Source Softw. 9, 7004 (2024).
35 */
36
37#ifndef APPLICATIONS_STATICPROPS_SFGTIMEAVG_HPP
38#define APPLICATIONS_STATICPROPS_SFGTIMEAVG_HPP
39
40#include <complex>
41#include <map>
42#include <string>
43#include <tuple>
44#include <utility>
45#include <vector>
46
47#include "applications/staticProps/StaticAnalyser.hpp"
50#include "math/Vector3.hpp"
51#include "selection/SelectionEvaluator.hpp"
52#include "selection/SelectionManager.hpp"
53
54namespace OpenMD {
55
56 /**
57 * @class SFGTimeAvg
58 *
59 * Computes vibrational SFG spectra in the OH-stretch region using the
60 * TIME-AVERAGING APPROXIMATION (TAA) of Auer & Skinner, rather than the
61 * dynamical adiabatic-propagator method implemented in the SFG dynamic
62 * property. The TAA is a single pass through the dump file: at each
63 * frame the instantaneous exciton Hamiltonian is built and diagonalized,
64 * and each eigenstate contributes a complex Lorentzian to the spectrum
65 * at its eigenfrequency, weighted by the eigenstate transition
66 * polarizability and transition dipole.
67 *
68 * chi2_pqr(w) = < sum_a (alpha_pq^a mu_r^a) / (w - w_a + i*Gamma) >
69 *
70 * where for eigenstate a:
71 * mu_r^a = sum_i V(i,a) mu_{r,i}
72 * alpha_pq^a = sum_i V(i,a) alpha_{pq,i}
73 *
74 * The TAA neglects motional narrowing (it is the inhomogeneous limit),
75 * but is far cheaper than the dynamical method (one diagonalization per
76 * frame, no correlation windows, no propagation). It shares the same
77 * spectroscopic maps and Hamiltonian construction as the dynamical SFG
78 * module so that the two are directly comparable.
79 *
80 * Fermi resonance with the HOH bend overtone is included by default
81 * (fc = 25 cm-1); set fc = 0 to disable.
82 */
83 class SFGTimeAvg : public StaticAnalyser {
84 public:
85 SFGTimeAvg(SimInfo* info, const std::string& filename,
86 const std::string& sele1, int nbins,
87 const std::string& polarization = "ssp",
88 int privilegedAxis = 2,
89 RealType gamma = 5.0, RealType fc = 25.0);
90
91 virtual void process();
92
93 private:
94 // -----------------------------------------------------------------------
95 // Per-frame chromophore data in the local (site) basis.
96 // Bend overtones (if Fermi resonance enabled) are appended after the
97 // OH stretches: indices [0..nStretch-1] stretches,
98 // [nStretch..N-1] bend overtones.
99 // -----------------------------------------------------------------------
100 struct FrameData {
101 int N {0};
102 int nStretch {0};
103 int nBend {0};
105 std::vector<Vector3d> mu;
106 std::vector<Mat3x3d> alpha;
107 };
108
109 // Build the chromophore list and Hamiltonian diagonal for the current
110 // snapshot. Fills ohPos (TDC dipole positions), molIndex, and the
111 // packed per-site array used by buildHamiltonian.
112 FrameData extractFrame(std::vector<Vector3d>& ohPos,
113 std::vector<int>& molIndex,
114 std::vector<RealType>& intraJ);
115
116 void buildHamiltonian(FrameData& fd,
117 const std::vector<Vector3d>& ohPos,
118 const std::vector<int>& molIndex,
119 const std::vector<RealType>& intraJ);
120
121 // Diagonalize a real symmetric matrix; fill evals and row-major
122 // eigenvectors evecs (evecs[i*N+a] = component i of eigenstate a).
123 void diagonalize(const DynamicRectMatrix<RealType>& H, int N,
124 std::vector<double>& evals,
125 std::vector<double>& evecs);
126
127 Mat3x3d bondPolarizability(const Vector3d& ohUnit,
128 RealType alpha_par, RealType alpha_perp,
129 RealType x10, RealType x10_gas);
130
131 RealType tdcCoupling(const Vector3d& r_ij,
132 const Vector3d& e_i, const Vector3d& e_j,
133 RealType mx_i, RealType mx_j);
134
135 void accumulateFrame(const FrameData& fd);
136 void writeSpectrum();
137
138 Snapshot* currentSnapshot_ {};
139
140 std::string selectionScript1_;
141 SelectionManager seleMan1_;
142 SelectionEvaluator evaluator1_;
143
144 // Spectroscopic maps (keyed by H atom-type name)
145 std::map<std::string, std::tuple<RealType,RealType,RealType>> w10_;
146 std::map<std::string, std::tuple<RealType,RealType,RealType>> muPrime_;
147 std::map<std::string, std::pair<RealType,RealType>> x10_;
148 std::map<std::string, std::pair<RealType,RealType>> p10_;
149 std::map<std::string, std::tuple<RealType,RealType,RealType>> wintra_;
150 std::map<std::string, std::pair<RealType,RealType>> alphaMap_;
151 std::map<std::string, RealType> tdcLoc_;
152
153 // Bend maps (keyed by water-model name)
154 std::map<std::string, std::pair<RealType,RealType>> wb01_;
155 std::map<std::string, std::pair<RealType,RealType>> wb12_;
156
157 std::string polarization_;
158 int privilegedAxis_ {2};
159 int s1_ {0};
160 int s2_ {1};
161 RealType gamma_ {5.0}; // Lorentzian half-width [cm-1]
162 RealType fc_ {25.0}; // Fermi coupling [cm-1]
163 bool useFermi_ {false};
164
165 int nProcessed_ {0};
166 RealType minFreq_ {2700.0};
167 RealType maxFreq_ {4000.0};
168
169 // Orientation diagnostics: accumulate <mu_z> by frequency class to
170 // verify dangling vs donor OHs point in opposite directions.
171 double diagMuzFree_ {0.0}; // freq > 3650 (dangling)
172 double diagMuzHB_ {0.0}; // freq < 3450 (H-bonded donor)
173 long diagNFree_ {0};
174 long diagNHB_ {0};
175
176 // Complex spectrum accumulators on the output grid
177 std::vector<std::complex<double>> chi2_;
178
179 Vector3d EF_;
180 bool dumpHasElectricFields_;
181 };
182} // namespace OpenMD
183
184#endif
Rectangular matrix class with contiguous flat storage.
"selection/SelectionEvaluator"
One of the heavy-weight classes of OpenMD, SimInfo maintains objects and variables relating to the cu...
Definition SimInfo.hpp:96
The Snapshot class is a repository storing dynamic data during a Simulation.
Definition Snapshot.hpp:166
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.