1 /*
2  *            Copyright 2009-2020 The VOTCA Development Team
3  *                       (http://www.votca.org)
4  *
5  *      Licensed under the Apache License, Version 2.0 (the "License")
6  *
7  * You may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *              http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  */
19 
20 #pragma once
21 #ifndef VOTCA_XTP_DENSITYANALYSIS_H
22 #define VOTCA_XTP_DENSITYANALYSIS_H
23 
24 // Standard includes
25 #include <cstdio>
26 
27 // Third party includes
28 #include <boost/filesystem.hpp>
29 
30 // Local VOTCA includes
31 #include "votca/xtp/gyration.h"
32 #include "votca/xtp/logger.h"
33 
34 namespace votca {
35 namespace xtp {
36 
37 class DensityAnalysis final : public QMTool {
38  public:
Identify()39   std::string Identify() const { return "densityanalysis"; }
40 
41  protected:
42   void ParseOptions(const tools::Property& user_options);
43   bool Run();
44 
45  private:
46   std::string orbfile_;
47   std::string output_file_;
48   tools::Property gyration_options_;
49 
50   Logger log_;
51 };
52 
ParseOptions(const tools::Property & options)53 void DensityAnalysis::ParseOptions(const tools::Property& options) {
54 
55   orbfile_ = options.ifExistsReturnElseReturnDefault<std::string>(
56       ".input", job_name_ + ".orb");
57 
58   gyration_options_ = options;
59 }
60 
Run()61 bool DensityAnalysis::Run() {
62   log_.setReportLevel(Log::current_level);
63   log_.setMultithreading(true);
64 
65   log_.setCommonPreface("\n... ...");
66 
67   Orbitals orbitals;
68   XTP_LOG(Log::error, log_)
69       << " Loading QM data from " << orbfile_ << std::flush;
70   orbitals.ReadFromCpt(orbfile_);
71 
72   Density2Gyration density2gyration(log_);
73   density2gyration.Initialize(gyration_options_);
74   density2gyration.AnalyzeDensity(orbitals);
75 
76   return true;
77 }
78 
79 }  // namespace xtp
80 }  // namespace votca
81 
82 #endif  // VOTCA_XTP_DENSITYANALYSIS_H
83