Source code for panpython.sdk.kinetic_opt.kinetic_optimize


"""
"Kinetic Optimization" Module
================================================
The core module of optimizing kinetic parameters
"""

from panpython._libs.optimize import KoptCore


[docs]class KdbBuilder: """ Parameters ---------- batch_file: str full path of batch file opt_file: str full path of opt file pandat_exe: str full path of pandat.exe Examples -------- >>> from panpython.sdk.kinetic_opt.kinetic_optimize import KdbBuilder >>> m_kdb = KdbBuilder(batch_file='template_batchfile.pbfx', ... opt_file='example.opt', ... dump_path='./kopt_output/', ... pandat_exe='pandat.exe') >>> m_kdb.fit_wrapper() """ def __init__(self, opt_file: str, dump_path: str, pandat_exe: str, batch_file: str = None): """Initialize Kdb Builder instance for kinetic optimization Parameters ---------- opt_file: str full path of opt file dump_path: str Location to dump results pandat_exe: str full path of pandat.exe batch_file: str full path of batch file, Optional if given in *.opt file Returns ------- """ self._kdb_opt = KoptCore(opt_file=opt_file, dump_path=dump_path, pandat_exe=pandat_exe, batch_file=batch_file) self._elapsed_pandat_time: float = -1.0 self._elapsed_solver_time: float = -1.0 @property def elapsed_pandat_time(self): """total time cost by Pandat.exe""" return self._elapsed_pandat_time @elapsed_pandat_time.setter def elapsed_pandat_time(self, val): raise ValueError("Assigning 'elapsed_pandat_time' is not allowed") @property def elapsed_solver_time(self): """total time cost of kinetic optimization""" return self._elapsed_solver_time @elapsed_solver_time.setter def elapsed_solver_time(self, val): raise ValueError("Assigning 'elapsed_solver_time' is not allowed")
[docs] def fit_wrapper(self): """a wrapper of fitting opt files Returns ------- """ self._kdb_opt.fit_boost() self._elapsed_pandat_time = self._kdb_opt.elapsed_pandat_time self._elapsed_solver_time = self._kdb_opt.elapsed_solver_time