diff --git a/.gitignore b/.gitignore index 2d3909b8..2c0ef0cc 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,8 @@ dptb/tests/data/test_all/test_config.json dptb/tests/data/test_all/checkpoint/best_nnsk_b5.000_c6.615_w0.265.json dptb/tests/data/test_all/checkpoint/best_nnsk_b4.000_c4.000_w0.300.json dptb/tests/data/test_all/fancy_ones/checkpoint/best_nnsk_b4.000_c4.000_w0.300.json +dptb/tests/data/test_negf/test_negf_run/out_negf/run_config.json +run_config.json dptb/nnet/__pycache__/ dptb/sktb/__pycache__/ dptb/negf/__pycache__/ diff --git a/dptb/entrypoints/run.py b/dptb/entrypoints/run.py index dfaea2d4..c9ba3a83 100644 --- a/dptb/entrypoints/run.py +++ b/dptb/entrypoints/run.py @@ -95,6 +95,9 @@ def run( task_options = j_must_have(jdata, "task_options") task = task_options["task"] + use_gui = jdata.get("use_gui", False) + task_options.update({"use_gui": use_gui}) + model_ckpt = run_opt["init_model"]["path"] # init_type = model_ckpt.split(".")[-1] # if init_type not in ["json", "pth"]: diff --git a/dptb/postprocess/bandstructure/band.py b/dptb/postprocess/bandstructure/band.py index f5f9bbd1..e9d10d1c 100644 --- a/dptb/postprocess/bandstructure/band.py +++ b/dptb/postprocess/bandstructure/band.py @@ -24,7 +24,8 @@ def __init__ (self, apiHrk, run_opt, jdata): self.apiH.update_struct(self.structase) self.ref_band = self.band_plot_options.get("ref_band", None) - + self.use_gui = self.band_plot_options.get("use_gui", False) + def get_bands(self): kline_type = self.band_plot_options['kline_type'] @@ -153,4 +154,5 @@ def band_plot(self): # remove the box around the plot ax.set_frame_on(False) plt.savefig(f'{self.results_path}/band.png',dpi=300) - plt.show() + if self.use_gui: + plt.show() diff --git a/dptb/postprocess/bandstructure/dos.py b/dptb/postprocess/bandstructure/dos.py index 7253af5c..96001e90 100644 --- a/dptb/postprocess/bandstructure/dos.py +++ b/dptb/postprocess/bandstructure/dos.py @@ -21,7 +21,7 @@ def __init__ (self, apiHrk, run_opt, jdata): self.dos_plot_options = jdata self.results_path = run_opt.get('results_path') self.apiH.update_struct(self.structase) - + self.use_gui = self.dos_plot_options.get("use_gui", False) def get_dos(self): self.mesh_grid = self.dos_plot_options['mesh_grid'] @@ -59,7 +59,8 @@ def dos_plot(self): plt.tick_params(direction='in') plt.tight_layout() plt.savefig(f'{self.results_path}/dos.png',dpi=300) - plt.show() + if self.use_gui: + plt.show() def _calc_dos(self, sigma=0.1, npoints=100, width=None, updata=False, kpoints=None): @@ -123,6 +124,8 @@ def __init__ (self, apiHrk, run_opt, jdata): for itype in apiHrk.structure.proj_atom_symbols: norbs = apiHrk.structure.proj_atomtype_norbs[itype] self.num_orbs_per_atom.append(norbs) + + self.use_gui = self.pdos_plot_options.get("use_gui", False) def get_pdos(self): self.mesh_grid = self.pdos_plot_options['mesh_grid'] @@ -183,7 +186,8 @@ def pdos_plot(self, atom_index=None, orbital_index=None): plt.tick_params(direction='in') plt.tight_layout() plt.savefig(f'{self.results_path}/proj_dos.png',dpi=300) - plt.show() + if self.use_gui: + plt.show() def _calc_pdos(self, sigma=0.1, npoints=100, width=None, updata=False, kpoints=None): diff --git a/dptb/tests/data/test_negf/test_negf_run/out_negf/run_config.json b/dptb/tests/data/test_negf/test_negf_run/out_negf/run_config.json deleted file mode 100644 index 9da7aa79..00000000 --- a/dptb/tests/data/test_negf/test_negf_run/out_negf/run_config.json +++ /dev/null @@ -1,151 +0,0 @@ -{ - "task_options": { - "task": "negf", - "scf": true, - "block_tridiagonal": false, - "ele_T": 300, - "unit": "Hartree", - "scf_options": { - "mode": "PDIIS", - "mixing_period": 3, - "step_size": 0.05, - "n_history": 6, - "abs_err": 1e-06, - "rel_err": 0.0001, - "max_iter": 100 - }, - "stru_options": { - "kmesh": [ - 1, - 1, - 1 - ], - "pbc": [ - false, - false, - false - ], - "device": { - "id": "4-8", - "sort": true - }, - "lead_L": { - "id": "0-4", - "voltage": 0.0 - }, - "lead_R": { - "id": "8-12", - "voltage": 0.0 - } - }, - "poisson_options": { - "solver": "fmm", - "err": 1e-05 - }, - "sgf_solver": "Sancho-Rubio", - "espacing": 0.1, - "emin": -2, - "emax": 2, - "e_fermi": -13.638587951660156, - "density_options": { - "method": "Ozaki", - "M_cut": 50, - "R": 1000000.0, - "n_gauss": 10 - }, - "eta_lead": 1e-05, - "eta_device": 0.0, - "out_dos": true, - "out_tc": true, - "out_ldos": true, - "out_current_nscf": true, - "out_density": false, - "out_potential": false, - "out_current": false, - "out_lcurrent": false - }, - "common_options": { - "onsitemode": "none", - "onsite_cutoff": 2.0, - "bond_cutoff": 2.0, - "env_cutoff": 2.0, - "atomtype": [ - "C" - ], - "proj_atom_neles": { - "C": 1 - }, - "proj_atom_anglr_m": { - "C": [ - "2s" - ] - }, - "device": "cpu", - "dtype": "float32", - "sk_file_path": "./", - "time_symm": true, - "soc": false, - "overlap": false, - "unit": "Hartree" - }, - "model_options": { - "sknetwork": { - "sk_hop_nhidden": 1, - "sk_onsite_nhidden": 1, - "sk_soc_nhidden": null - }, - "skfunction": { - "sk_cutoff": 1.6, - "sk_decay_w": 0.3, - "skformula": "powerlaw" - }, - "onsitefuncion": { - "onsite_func_cutoff": 6.0, - "onsite_func_decay_w": 0.5, - "onsite_func_lambda": 1.0 - }, - "dptb": { - "soc_env": false, - "axis_neuron": 10, - "onsite_net_neuron": [ - 128, - 128, - 256, - 256 - ], - "soc_net_neuron": [ - 128, - 128, - 256, - 256 - ], - "env_net_neuron": [ - 128, - 128, - 256, - 256 - ], - "hopping_net_neuron": [ - 128, - 128, - 256, - 256 - ], - "onsite_net_activation": "tanh", - "env_net_activation": "tanh", - "hopping_net_activation": "tanh", - "soc_net_activation": "tanh", - "onsite_net_type": "res", - "env_net_type": "res", - "hopping_net_type": "res", - "soc_net_type": "res", - "if_batch_normalized": false - } - }, - "init_model": { - "path": "D:\\KnowledgeLibrary\\DeePTB\\DeePTB_formal/dptb/tests/data/test_negf/test_negf_run/nnsk_C.json", - "interpolate": false - }, - "structure": null, - "use_correction": null -} \ No newline at end of file diff --git a/dptb/utils/argcheck.py b/dptb/utils/argcheck.py index dded8dd2..557acbdb 100644 --- a/dptb/utils/argcheck.py +++ b/dptb/utils/argcheck.py @@ -593,6 +593,7 @@ def normalize_run(data): doc_structure = "" doc_use_correction = "" doc_overlap = "" + doc_gui = "" args = [ Argument("onsite_cutoff", float, optional = False, doc = doc_onsite_cutoff), @@ -621,6 +622,7 @@ def normalize_run(data): mo, Argument("structure", [str,None], optional=True, default=None, doc = doc_structure), Argument("use_correction", [str,None], optional=True, default=None, doc = doc_use_correction), + Argument("use_gui", bool, optional=True, default=False, doc = doc_gui), Argument("task_options", dict, sub_fields=[], optional=True, sub_variants=[task_options()], doc = doc_property) ]