ComputeMLWFCmd.C 2.43 KB
Newer Older
Francois Gygi committed
1 2
////////////////////////////////////////////////////////////////////////////////
//
Francois Gygi committed
3 4 5 6
// Copyright (c) 2008 The Regents of the University of California
//
// This file is part of Qbox
//
Francois Gygi committed
7 8
// Qbox is distributed under the terms of the GNU General Public License
// as published by the Free Software Foundation, either version 2 of
Francois Gygi committed
9 10 11 12 13 14
// the License, or (at your option) any later version.
// See the file COPYING in the root directory of this distribution
// or <http://www.gnu.org/licenses/>.
//
////////////////////////////////////////////////////////////////////////////////
//
Francois Gygi committed
15 16 17
// ComputeMLWFCmd.C:
//
////////////////////////////////////////////////////////////////////////////////
Francois Gygi committed
18
// $Id: ComputeMLWFCmd.C,v 1.8 2008-11-14 22:11:30 fgygi Exp $
Francois Gygi committed
19 20 21 22 23 24 25

#include "ComputeMLWFCmd.h"
#include<iostream>
#include "Context.h"
#include "SlaterDet.h"
using namespace std;

Francois Gygi committed
26
////////////////////////////////////////////////////////////////////////////////
Francois Gygi committed
27 28 29 30
int ComputeMLWFCmd::action(int argc, char **argv)
{
  Wavefunction& wf = s->wf;
  SlaterDet& sd = *(wf.sd(0,0));
31

32 33 34 35 36 37 38 39 40 41 42
  // Check that only the k=0 point is used
  if ( wf.nkp()>1 || !sd.basis().real() )
  {
    if ( ui->onpe0() )
    {
      cout << " ComputeMLWFCmd::action: compute_mlwf can only be used at\n"
           << " the Gamma point (k=0)" << endl;
    }
    return 1;
  }

Francois Gygi committed
43
  MLWFTransform* mlwft = new MLWFTransform(sd);
44

Francois Gygi committed
45 46
  mlwft->compute_transform();
  mlwft->apply_transform(sd);
Francois Gygi committed
47 48 49 50 51 52 53 54 55 56

  if ( ui->onpe0() )
  {
    cout << " <mlwf_set size=\"" << sd.nst() << "\">" << endl;
    for ( int i = 0; i < sd.nst(); i++ )
    {
      D3vector ctr = mlwft->center(i);
      double sp = mlwft->spread(i);
      cout.setf(ios::fixed, ios::floatfield);
      cout.setf(ios::right, ios::adjustfield);
57
      cout << "   <mlwf center=\"" << setprecision(6)
Francois Gygi committed
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
           << setw(12) << ctr.x
           << setw(12) << ctr.y
           << setw(12) << ctr.z
           << " \" spread=\" " << sp << " \"/>"
           << endl;
    }
    cout << " </mlwf_set>" << endl;
    D3vector edipole = mlwft->dipole();
    cout << " <electronic_dipole> " << edipole
         << " </electronic_dipole>" << endl;
    D3vector idipole = s->atoms.dipole();
    cout << " <ionic_dipole> " << idipole
         << " </ionic_dipole>" << endl;
    cout << " <total_dipole> " << idipole + edipole
         << " </total_dipole>" << endl;
    cout << " <total_dipole_length> " << length(idipole + edipole)
         << " </total_dipole_length>" << endl;
  }
Francois Gygi committed
76
  delete mlwft;
Francois Gygi committed
77
  return 0;
Francois Gygi committed
78
}