1 | #include <iostream>
|
---|
2 | #include <sstream>
|
---|
3 | #include <iomanip>
|
---|
4 | #include <chemistry/qc/basis/basis.h>
|
---|
5 | #include <chemistry/molecule/atominfo.h>
|
---|
6 | #include <Chemistry_QC_GaussianBasis_Molecular.hh>
|
---|
7 | #include <Chemistry_Molecule.hh>
|
---|
8 |
|
---|
9 | using namespace std;
|
---|
10 | using namespace sc;
|
---|
11 | using namespace Chemistry;
|
---|
12 | using namespace Chemistry::QC::GaussianBasis;
|
---|
13 |
|
---|
14 | Ref<GaussianBasisSet> basis_cca_to_sc( Molecular &cca_basis ) {
|
---|
15 |
|
---|
16 | const char* am_to_symbol[] = {"s", "p", "d", "f", "g", "h", "i", "k", "l",
|
---|
17 | "m", "n", "o", "p", "q", "r", "s", "t", "u",
|
---|
18 | "v", "w", "x", "y", "z"};
|
---|
19 |
|
---|
20 | //cca_basis.print_molecular();
|
---|
21 |
|
---|
22 | Chemistry::Molecule cca_mol = cca_basis.get_molecule();
|
---|
23 |
|
---|
24 | ostringstream input;
|
---|
25 |
|
---|
26 | // form molecule keyval
|
---|
27 | double conv = cca_mol.get_units().convert_to("bohr");
|
---|
28 | input
|
---|
29 | << "molecule<Molecule>: (\n"
|
---|
30 | << " symmetry = auto\n"
|
---|
31 | << " unit = bohr\n"
|
---|
32 | << " {n atoms geometry } = {\n";
|
---|
33 | for( int i=0; i<cca_mol.get_n_atom(); ++i ) {
|
---|
34 | input << setprecision(16);
|
---|
35 | input << "\t" << i << "\t" << cca_mol.get_atomic_number(i)
|
---|
36 | << "\t[ " << cca_mol.get_cart_coor(i,0)*conv
|
---|
37 | << " " << cca_mol.get_cart_coor(i,1)*conv
|
---|
38 | << " " << cca_mol.get_cart_coor(i,2)*conv << " ]\n";
|
---|
39 | }
|
---|
40 | input << " }\n" << ")\n";
|
---|
41 |
|
---|
42 | // form basis keyval
|
---|
43 | input.precision(18);
|
---|
44 | input << "scbasis<GaussianBasisSet>:(\n"
|
---|
45 | << " molecule = $:molecule\n"
|
---|
46 | << " basis = [";
|
---|
47 | for(int i=0; i<cca_mol.get_n_atom(); ++i)
|
---|
48 | input << " basis" << i;
|
---|
49 | input << " ]\n" << ")\n";
|
---|
50 |
|
---|
51 | input << "basis:(\n";
|
---|
52 |
|
---|
53 | // form atomic set for each individual center (possibly redundant)
|
---|
54 | // <atomname>: <basisname>: [
|
---|
55 | AtomInfo empty_info;
|
---|
56 | for(int i=0; i<cca_mol.get_n_atom(); ++i) {
|
---|
57 | Atomic atomic = cca_basis.get_atomic(i);
|
---|
58 | input << " " << empty_info.name( cca_mol.get_atomic_number(i) ) << ": "
|
---|
59 | << " basis" << i << ": [\n";
|
---|
60 |
|
---|
61 | // form shells
|
---|
62 | for(int ishell=0; ishell<atomic.get_n_shell(); ++ishell) {
|
---|
63 | Shell shell = atomic.get_shell(ishell);
|
---|
64 | // (type: [ am = <symbol> ...]
|
---|
65 | input << " (normalized = 0\n";
|
---|
66 | //input << " (normalized = 1\n";
|
---|
67 | input << " type: [";
|
---|
68 | for(int icon=0; icon<shell.get_n_contraction(); ++icon) {
|
---|
69 | input << " (am = " << am_to_symbol[shell.get_angular_momentum(icon)];
|
---|
70 | if( shell.get_max_angular_momentum() > 1 ) {
|
---|
71 | if( shell.get_angular_type() == AngularType_CARTESIAN )
|
---|
72 | input << " puream = 0)";
|
---|
73 | else if( shell.get_angular_type() == AngularType_SPHERICAL )
|
---|
74 | input << " puream = 1)";
|
---|
75 | else if( shell.get_angular_type() == AngularType_MIXED )
|
---|
76 | std::cerr << " mixed angular types?";
|
---|
77 | }
|
---|
78 | else input << ")";
|
---|
79 | }
|
---|
80 | input << "]\n";
|
---|
81 | // {exp coef:<am> ...} = {
|
---|
82 | input << " {exp";
|
---|
83 | for(int icon=0; icon<shell.get_n_contraction(); ++icon)
|
---|
84 | input << " coef:" << icon;
|
---|
85 | input << "} = {\n";
|
---|
86 | // <exp> <coef> ...
|
---|
87 | for(int iprim=0; iprim<shell.get_n_primitive(); ++iprim) {
|
---|
88 | input << "\t" << shell.get_exponent(iprim);
|
---|
89 | for(int icon=0; icon<shell.get_n_contraction(); ++icon)
|
---|
90 | input << "\t" << shell.get_contraction_coef(icon, iprim);
|
---|
91 | input << endl;
|
---|
92 | }
|
---|
93 | input << "\n })\n";
|
---|
94 | }
|
---|
95 | input << " ]\n";
|
---|
96 | }
|
---|
97 | input << ")\n";
|
---|
98 |
|
---|
99 | //cout << " basis input:\n" << input.str() << endl;
|
---|
100 |
|
---|
101 | Ref<ParsedKeyVal> kv = new ParsedKeyVal();
|
---|
102 | kv->parse_string( input.str().c_str() );
|
---|
103 | Ref<DescribedClass> dc = kv->describedclassvalue("scbasis");
|
---|
104 | GaussianBasisSet *sc_basis =
|
---|
105 | dynamic_cast< GaussianBasisSet* >( dc.pointer() );
|
---|
106 |
|
---|
107 | Ref<GaussianBasisSet> gbs;
|
---|
108 | gbs.assign_pointer(sc_basis);
|
---|
109 |
|
---|
110 | //for(int i=0; i<gbs->nshell(); ++i)
|
---|
111 | // gbs->shell(i).print();
|
---|
112 |
|
---|
113 | return gbs;
|
---|
114 | }
|
---|