• R/O
  • HTTP
  • SSH
  • HTTPS

Molby: コミット

Molecular Modeling Software


コミットメタ情報

リビジョン75d353565187694f6e15a81357e11690b1336a26 (tree)
日時2022-09-25 19:53:08
作者Toshi Nagata <alchemist.2005@nift...>
コミッターToshi Nagata

ログメッセージ

Psi4 execution is improved (avoid duplicate import of geometries etc.)

変更サマリ

差分

--- a/MolLib/Ruby_bind/ruby_bind.c
+++ b/MolLib/Ruby_bind/ruby_bind.c
@@ -756,10 +756,10 @@ s_Kernel_RegisterMenu(int argc, VALUE *argv, VALUE self)
756756 sNonEmptyProc = rb_eval_string("lambda { |m| m.is_a?(Molecule) && m.natoms > 0 }");
757757 sSelectionProc = rb_eval_string("lambda { |m| m.is_a?(Molecule) && m.selection.count > 0 }");
758758 sTrueProc = rb_eval_string("lambda { |m| true }");
759- rb_global_variable(&sMolProc);
760- rb_global_variable(&sNonEmptyProc);
761- rb_global_variable(&sSelectionProc);
762- rb_global_variable(&sTrueProc);
759+ rb_define_variable("$is_a_molecule_proc", &sMolProc);
760+ rb_define_variable("$is_molecule_not_empty_proc", &sNonEmptyProc);
761+ rb_define_variable("$has_molecule_selection_proc", &sSelectionProc);
762+ rb_define_variable("$always_true_proc", &sTrueProc);
763763 }
764764
765765 if (pval == Qnil) {
--- a/Scripts/gamess.rb
+++ b/Scripts/gamess.rb
@@ -1609,51 +1609,7 @@ class Molecule
16091609 nalpha = nil
16101610 nbeta = nil
16111611
1612- term_callback = lambda { |m, n|
1613- begin
1614- msg = "Psi4 execution of #{inpbase}"
1615- hmsg = "Psi4 "
1616- if n == 0
1617- msg += "succeeded."
1618- hmsg += "Completed"
1619- icon = :info
1620- else
1621- msg += "failed with status #{n}."
1622- hmsg += "Failed"
1623- icon = :error
1624- end
1625- msg += "\n(In directory #{inpdir})"
1626- ENV["PATH"] = orgpath
1627- Dir.chdir(orgdir)
1628- if mol != nil
1629- message_box(msg, hmsg, :ok, icon)
1630- end
1631- if n == 0
1632- # Try to load molden file if available
1633- mol.clear_basis_set
1634- mol.clear_mo_coefficients
1635- mol.set_mo_info(:type => hf_type, :alpha => nalpha, :beta => nbeta)
1636- molden = inpdir + "/" + inpbody +".molden"
1637- if File.exists?(molden)
1638- fp = Kernel.open(molden, "rt")
1639- mol.instance_eval { @lineno = 0 }
1640- begin
1641- # mol.@hf_type should be set before calling sub_load_molden
1642- mol.sub_load_molden(fp)
1643- fp.close
1644- rescue => e
1645- print(e.message + "\n")
1646- print(e.backtrace.inspect + "\n")
1647- end
1648- end
1649- end
1650- rescue => e
1651- print("#{e.message}\n")
1652- print("#{e.backtrace.to_s}\n")
1653- end
1654- true
1655- }
1656-
1612+ # Timer callback
16571613 timer_count = 0
16581614 fplog = nil
16591615 last_size = 0
@@ -1668,11 +1624,16 @@ class Molecule
16681624 end
16691625 timer_count = 0
16701626 if fplog == nil
1671- fplog = Kernel.open(inpdir + "/" + inpbody + ".out", "rt")
1672- if fplog == nil
1673- return true
1627+ outfile = inpdir + "/" + inpbody + ".out"
1628+ if File.exists?(outfile)
1629+ fplog = Kernel.open(inpdir + "/" + inpbody + ".out", "rt")
1630+ if fplog == nil
1631+ return true
1632+ end
1633+ last_size = 0
1634+ else
1635+ return true # Skip until outfile is available
16741636 end
1675- last_size = 0
16761637 end
16771638 fplog.seek(0, IO::SEEK_END)
16781639 current_size = fplog.tell
@@ -1745,7 +1706,7 @@ class Molecule
17451706 end
17461707 end
17471708 if next_index > 0
1748- lines.slice!(next_index, lines.length - next_index)
1709+ lines.slice!(0, next_index)
17491710 next_index = 0
17501711 end
17511712 return true
@@ -1756,6 +1717,56 @@ class Molecule
17561717 return false
17571718 end
17581719 }
1720+
1721+ # Terminate callback
1722+ term_callback = lambda { |m, n|
1723+ begin
1724+ msg = "Psi4 execution of #{inpbase} "
1725+ hmsg = "Psi4 "
1726+ if n == 0
1727+ msg += "succeeded."
1728+ hmsg += "Completed"
1729+ icon = :info
1730+ else
1731+ msg += "failed with status #{n}."
1732+ hmsg += "Failed"
1733+ icon = :error
1734+ end
1735+ msg += "\n(In directory #{inpdir})"
1736+ ENV["PATH"] = orgpath
1737+ Dir.chdir(orgdir)
1738+ if mol != nil
1739+ message_box(msg, hmsg, :ok, icon)
1740+ end
1741+ if n == 0
1742+ # Try to load final lines of the logfile
1743+ timer_count = 100
1744+ timer_callback.call(m, n)
1745+ # Try to load molden file if available
1746+ mol.clear_basis_set
1747+ mol.clear_mo_coefficients
1748+ mol.set_mo_info(:type => hf_type, :alpha => nalpha, :beta => nbeta)
1749+ molden = inpdir + "/" + inpbody +".molden"
1750+ if File.exists?(molden)
1751+ fp = Kernel.open(molden, "rt")
1752+ mol.instance_eval { @lineno = 0 }
1753+ begin
1754+ # mol.@hf_type should be set before calling sub_load_molden
1755+ mol.sub_load_molden(fp)
1756+ fp.close
1757+ rescue => e
1758+ print(e.message + "\n")
1759+ print(e.backtrace.inspect + "\n")
1760+ end
1761+ end
1762+ end
1763+ rescue => e
1764+ print("#{e.message}\n")
1765+ print("#{e.backtrace.to_s}\n")
1766+ end
1767+ true
1768+ }
1769+
17591770
17601771 if mol
17611772 pid = mol.call_subprocess_async(cmdline, term_callback, timer_callback)
--- a/wxSources/MyApp.cpp
+++ b/wxSources/MyApp.cpp
@@ -1170,7 +1170,7 @@ MyApp::OnUpdateUI(wxUpdateUIEvent& event)
11701170 checked = -1;
11711171 title = NULL;
11721172 enabled = Ruby_UpdateUI(index, mol, &checked, &title);
1173- if (checked >= 0)
1173+ if (checked >= 0 && event.IsCheckable())
11741174 event.Check(checked != 0);
11751175 if (title != NULL) {
11761176 wxString wtext(title, WX_DEFAULT_CONV);
旧リポジトリブラウザで表示