30 m_filePositions.reset();
31 m_filePositions = arma::zeros(1,20*20*20,3);
34 for(
int i = 0; i < nPerDim; i++) {
35 for(
int j = 0; j < nPerDim; j++) {
36 for(
int k = 0; k < nPerDim; k++) {
37 m_filePositions(0,counter,0) = -nPerDim / 2 + i;
38 m_filePositions(0,counter,1) = -nPerDim / 2 + j;
39 m_filePositions(0,counter,2) = -nPerDim / 2 + k;
51 return m_orbitalDensities(0).n_rows;
56 return m_orbitalDensities(0).n_cols;
61 return m_orbitalDensities(0).n_slices;
66 return m_filePositions;
73 vec x = linspace(-edge, edge, 50);
74 vec y = linspace(-edge, edge, 50);
75 vec z = linspace(-edge, edge, 50);
76 cout <<
"Solving system with Hartree-Fock..." << endl;
77 vector<GaussianCore> cores;
79 cores.push_back(
GaussianCore({ -5, 0.0, 0.0000},
"atom_1_basis_6-311++Gdsds.tm"));
80 cores.push_back(
GaussianCore({ 5, 0.0, 0.0000},
"atom_1_basis_6-311++Gdsds.tm"));
92 cout <<
"Energy: " << solver.
energy() << endl;
95 m_orbitalDensities.set_size(C.n_cols);
96 m_totalDensity = zeros(x.n_elem, y.n_elem, z.n_elem);
97 for(cube& orbitalDensity : m_orbitalDensities) {
98 orbitalDensity = zeros(x.n_elem, y.n_elem, z.n_elem);
100 cout <<
"Calculating density..." << endl;
101 double maxDensity = 0.0;
102 double densitySum = 0.0;
103 for(uint i = 0; i < x.n_elem; i++) {
104 for(uint j = 0; j < y.n_elem; j++) {
105 for(uint k = 0; k < z.n_elem; k++) {
108 double density = orbitalDensities(
orbital);
109 densitySum += density;
110 m_totalDensity(i,j,k) += density;
111 m_orbitalDensities(
orbital)(i,j,k) = density;
112 maxDensity = fmax(maxDensity, density);
117 int elementCount = x.n_elem * y.n_elem * z.n_elem;
118 double meanDensity = (densitySum / elementCount);
119 m_totalDensity /= (meanDensity * m_orbitalDensities.n_elem);
120 for(cube& orbitalDensity : m_orbitalDensities) {
121 orbitalDensity /= meanDensity;
123 m_energy = solver.
energy();
125 double minValue = x.min();
126 double maxValue = x.max();
127 double mostMaxValue = max(-minValue, maxValue);
128 minValue = -mostMaxValue;
129 maxValue = mostMaxValue;
131 m_voxelEdgeMin = minValue;
132 m_voxelEdgeMax = maxValue;
140 if(m_orbitalDensities.n_elem < 1) {
144 delete[] m_voxelData;
146 uint nElements = m_orbitalDensities(0).n_rows * m_orbitalDensities(0).n_cols * m_orbitalDensities(0).n_slices;
147 m_voxelData =
new GLuint[nElements];
148 cube *densityPointer = &m_totalDensity;
149 if(m_orbital != -1) {
150 densityPointer = &(m_orbitalDensities(m_orbital));
152 cube &density = *densityPointer;
153 uint rowCount = density.n_rows;
154 uint colCount = density.n_rows;
155 uint sliceCount = density.n_rows;
157 for(uint i = 0; i < (rowCount); i++) {
158 for(uint j = 0; j < (colCount); j++) {
159 for(uint k = 0; k < (sliceCount); k++) {
162 + k * colCount * rowCount;
163 double value = density(i,j,k);
165 value = fmin(1.0, value);
166 m_voxelData[index] = value * 2147483647;
180 if (m_orbital != arg) {