OSDN Git Service

Description of JANPA orbitals is improved (distinction between LP and core)
authorToshi Nagata <alchemist.2005@nifty.com>
Sun, 16 Oct 2022 14:28:39 +0000 (23:28 +0900)
committerToshi Nagata <alchemist.2005@nifty.com>
Sun, 16 Oct 2022 14:28:39 +0000 (23:28 +0900)
Scripts/commands.rb
Scripts/gamess.rb
Scripts/loadsave.rb
wxSources/MoleculeView.cpp

index 6acd6f7..4e1b6d0 100755 (executable)
@@ -373,7 +373,7 @@ class Molecule
          ncomps = mol.get_mo_info(:ncomps)
          mo_index = 1
          mo_ao = nil
-         coltable = [[0,0,1], [1,0,0], [0,1,0], [1,1,0], [0,1,1], [1,0,1], [0,0,0]]
+         coltable = [[0,0,1], [1,0,0], [0,1,0], [1,1,0], [0,1,1], [1,0,1], [0,0,0], [1,1,1]]
          mo_ao_items = ["Molecular Orbitals", "Atomic Orbitals"]
          mo_ao_keys = ["MO", "AO"]
       if (nbo = mol.instance_eval { @nbo }) != nil
@@ -516,7 +516,14 @@ class Molecule
                  end
                else
                  mo_index = mo
-                 occ_new = occ
+      occ_new = occ
+      if mo_menu[mo]
+        if mo_menu[mo] =~ /(\(ryd?)|(\(NB)|(\*)/
+          occ_new = 0
+        else
+          occ_new = 1
+        end
+      end
                end
                coeffs = nil
                if occ_new != occ
@@ -578,7 +585,7 @@ class Molecule
                  end
                  it0 = item_with_tag("mo")
                  it0[:subitems] = mo_menu
-                 it0[:value] = 0
+      #it0[:value] = 0   #  Keep the mo number invariant
                  h["mo"] = nil  # "Update" button is forced to be enabled
                  on_mo_action.call(it0)
                end
@@ -631,7 +638,7 @@ class Molecule
              item(:popup, :tag=>"mo", :subitems=>mo_menu, :action=>on_mo_action)),
                layout(4,
                  item(:text, :title=>"Color"),
-                 item(:popup, :tag=>"color", :subitems=>["blue", "red", "green", "yellow", "cyan", "magenta", "black"], :action=>on_action),
+                 item(:popup, :tag=>"color", :subitems=>["blue", "red", "green", "yellow", "cyan", "magenta", "black", "white"], :action=>on_action),
                  item(:text, :title=>"Opacity"),
                  item(:textfield, :tag=>"opacity", :width=>80, :value=>"0.8", :action=>on_action),
                  item(:text, :title=>"Threshold"),
index 94c74fe..547aaf6 100755 (executable)
@@ -1958,7 +1958,7 @@ class Molecule
     dfttype_desc = ["B3LYP"]
     runtype_desc = ["Energy", "Optimize"]
     scftype_desc = ["RHF", "ROHF", "UHF"]
-    nbo_desc = ["nao", "pnao", "aho", "lho", "lpo", "clpo"]  #  JANPA
+    nbo_desc = ["nao", "pnao", "aho", "lho", "plho", "lpo", "clpo"]  #  JANPA
     user_input = Hash.new
     defaults = {"scftype"=>0, "runtype"=>0, "move_to_com"=>0, "do_reorient"=>0,
       "use_symmetry"=>0,  "charge"=>"0", "mult"=>"1",
index eb967ba..8f4e3b1 100755 (executable)
@@ -760,11 +760,11 @@ class Molecule
             while line = getline.call
               if line =~ /^ *Sym= *(\w+)/
                 sym = $1
-              elsif line =~ /^ *Ene= *([-+.0-9e]+)/
+              elsif line =~ /^ *Ene= *([-+.0-9eE]+)/
                 ene = Float($1)
               elsif line =~ /^ *Spin= *(\w+)/
                 spin = $1
-              elsif line =~ /^ *Occup= *([-+.0-9e]+)/
+              elsif line =~ /^ *Occup= *([-+.0-9eE]+)/
                 occ = Float($1)
                 if occ > 0.0
                   if spin == "Alpha"
@@ -776,7 +776,7 @@ class Molecule
                 if label
                   hash[:moinfo].push([sym, ene, (spin == "Alpha" ? 0 : 1), occ])
                 end
-              elsif line =~ /^ *([0-9]+) +([-+.0-9e]+)/
+              elsif line =~ /^ *([0-9]+) +([-+.0-9eE]+)/
                 m[i] = Float($2)
                 i += 1
                 if i >= ncomps
@@ -787,9 +787,10 @@ class Molecule
                     idx = idx_beta
                     idx_beta += 1
                   end
-                  set_mo_coefficients(idx, ene, m)
                   if label
                     hash[:mo].push(m.dup)
+                  else
+                    set_mo_coefficients(idx, ene, m)
                   end
                   break
                 end
@@ -1149,6 +1150,31 @@ class Molecule
         #  Copy labels from LHO
         @nbo["AHO_L"] = @nbo["LHO_L"].dup
       end
+      if @nbo["AO/NAO"] && @nbo["NAO_L"]
+        #  Make distinction between "LP" and "core" orbitals
+        ["AHO", "LHO", "LPO", "CLPO"].each { |key|
+          next if !@nbo["AO/" + key] || !@nbo[key + "_L"]
+          nao2key = @nbo["AO/NAO"].inverse * @nbo["AO/" + key]
+          @nbo[key + "_L"].each_with_index { |label, index|
+            if label =~ /\(((LP)|(lp)),/
+              max_val = -1
+              max_idx = nil
+              nao_num.times { |idx|
+                w = nao2key[index, idx] ** 2
+                if w > max_val
+                  max_val = w
+                  max_idx = idx
+                end
+              }
+              nao_label = @nbo["NAO_L"][max_idx]
+              if nao_label =~ /\(core,/
+                label.gsub!(/\(((LP)|(lp)),/, "(core,")
+                @nbo[key + "_L"][index] = label
+              end
+            end
+          }
+        }
+      end
       return true
     rescue => e
       $stderr.write(e.message + "\n")
index 5556ce4..a78f0cf 100755 (executable)
@@ -714,8 +714,14 @@ MoleculeView::OnSliderAction(wxCommandEvent& event)
     
        MoleculeLock(mview->mol);
        MainView_rotateBySlider(mview, angle * 3.1415927 * 2, mode, mouseStatus, MainViewCallback_modifierFlags(NULL));
+
+    //  We do not use here MainViewCallback_drawInfoText(), because the character
+    //  "°" here is written in UTF-8 encoding, whereas MainViewCallback_drawInfoText()
+    //  accepts a C string in native encoding (shift-JIS in Windows)
     snprintf(buf, sizeof buf, "%.1f°", angledeg);
-    MainViewCallback_drawInfoText(mview, buf);
+    wxString labelstr(buf, wxConvUTF8);  //  force UTF-8 encoding here
+    infotext->SetLabel(labelstr);
+
     MainViewCallback_updateCanvas(mview);
        MoleculeUnlock(mview->mol);
 }