def write_script(self): print 'Writing the lammps script' _mainpage_ = get_entriesvalue(self.s_entry_c) _flag_ = True # data ok flag _entries_ = [ 'float', 'int', 'int', 'float:', 'float', 'int', 'float:', 'float', 'float:', 'float' ] _flag_ *= self.check_datafile(bool) _flag_ *= min(check_vars(_mainpage_[1:], _entries_)) if _flag_: self._container_['mainpage'] = _mainpage_ _script_setup_ = [ _mainpage_, self._container_['advanced'][0], self._container_['restrain'] ] self.master._script_ = self._container_ _flag_ = write_lammps_input(_script_setup_, self._convertdata_) if _flag_: print_dec_g('Lammps script done!') self.master.swapbody(3)
def run_script( _file_, machine='lammps', _cores_='1'): core_flag = min(check_vars([_cores_],['int'],'Run aborted!')) if check_file(_file_) and core_flag: print _file_ command = '{} -echo both -in {}'.format( machine, _file_) if int(_cores_)>1: command = 'mpirun -np {} '.format( _cores_) + command run_command(command)
def config_restrain(self): title_txt = ' ' * 28 + '+ Restrain Goups' instructions = 'Select the group to restrain' #============ grouping ================ max_index = self.check_datafile() if max_index: _defvals_ = self._container_['restrain'] if _defvals_ == []: g_names = ['all_group'] d_ids = ['{}:{}'.format(1, max_index)] kxyz_c = ['1:xyz'] rest_ens = ['1-2'] #restrained_ensembles ck_init = [0] second_c = None if self._convertdata_ <> None: _mol_niifi_ = self._convertdata_['atomsdata'][1] for mt in range(len(_mol_niifi_)): g_names.append(_mol_niifi_[mt][0]) d_ids.append('{}:{}'.format(*_mol_niifi_[mt][1:])) kxyz_c += ['1:xyz'] rest_ens += ['1-2'] ck_init += [0] else: g_names, d_ids, kxyz_c, rest_ens, ck_init = _defvals_[0] #print g_names,'\n', d_ids,'\n', kxyz_c,'\n', ck_init if _defvals_[1] <> None: second_c = _defvals_[1] else: second_c = None self.resb.config(bg='gray70') #, width = 45) #cyan') self.master._aux_ = [] pop = PromptPopUp_wck( master=self.master, title=title_txt, briefing=instructions, entries_txt=g_names, entries_val=kxyz_c, width=530, #height = 365, range_id=d_ids, res_ens=rest_ens, chck_init=ck_init, extra_but=second_c, ) pop.wait_window() if self.master._aux_ <> []: sim_len = 0 for x in self._container_['advanced'][0][-2].split('-'): if x.strip(' ') <> 'R': sim_len += 1 _res_flag_ = [[], []] _restrain_ = self.master._aux_[:] _, _d_ids, _kxyz_c, _runs_c, _res_flag_[0] = _restrain_[0] if _restrain_[1] <> None: _, au2, au3, au4, au5 = _restrain_[1][:] _restrain_aux = _d_ids + au2 + _kxyz_c + au3 + _runs_c + au4 _res_flag_[1] = au5 else: _restrain_aux = _d_ids + _kxyz_c + _runs_c _multi_ = len(_restrain_aux) / 3 _entries_ = ([['<int:int<', 1, max_index]] * _multi_ + ['float:xyz'] * _multi_ + [['<int-x-int<:0', 1, sim_len]] * _multi_) _aux_ = check_vars(_restrain_aux, _entries_, 'Restrain groups not saved!') #print _aux_ _flag_ = min(_aux_) if _flag_: if max(max(_res_flag_)): self._container_['restrain'] = _restrain_ print_dec_g('Restrain data saved') else: print('Creating 0 groups, Restraining 0 atoms') self.resb.config(bg='gray86') #, width = 45)
def further_config_script(self): defvals = [] title_txt = ' ' * 3 + '+ Simulation Parameters' instructions = 'Input further simulation parameters' askfor = [ 'Thermo output every [#ts]', 'Atom mapping', 'Pairwise interactions', "L-J/Buck rcutoff [" + u'\u00c5' + "]", "Coulomb rcutoff [" + u'\u00c5' + "]", "Neighbor skin distance [" + u'\u00c5' + "]", 'Long-range solver', 'Long-range relative error', 'Interaction 1-2:1-3:1-4', 'Neighbor delay [#ts]', 'Neighbor update [#ts]', 'Pressure control', 'Force mixing rule', 'Simulation order', 'Velocity creation Temp [K]', ] _pair_style_ = [ 'lj/cut/coul/long', 'lj/cut/coul/cut', 'lj/cut', 'buck/coul/long', 'buck', 'buck/coul/cut', #'lj/cut/tip4p/cut', 'lj/cut/tip4p/long', #'lj/gromacs', 'lj/gromacs/coul/gromacs', 'zero', 'none' ] if self._convertdata_ <> None: buckorlj = int(self._convertdata_['defaults'][0]) if buckorlj == 1: _pair_style_ = _pair_style_[:3] + _pair_style_[-2:] else: _pair_style_ = _pair_style_[3:] self._container_['advanced'][0][2] = _pair_style_[3] _kspace_ = [ 'pppm', 'pppm/cg', 'ewald', 'pppm/disp', 'ewald/disp', #'pppm/tip4p', 'pppm/disp/tip4p' ] _comb_rule_ = ['No', 'geometric', 'arithmetic', 'sixthpower'] self._container_['advanced'][1] = [ '', ['array', 'hash'], _pair_style_, '', '', '', _kspace_, '', '', '', '', ['aniso', 'iso', 'tri'], _comb_rule_, '', '' ] _defvals_ = [] for _ad_ in range(len(self._container_['advanced'][0])): if self._container_['advanced'][1][_ad_] <> '': _def_ = self._container_['advanced'][0][_ad_] _dfli_ = self._container_['advanced'][1][_ad_] _defvals_.append([_def_, _dfli_]) else: _defvals_.append(self._container_['advanced'][0][_ad_]) self.fcb.config(bg='gray70') #, width = 155) #cyan') self.master._aux_ = [] pop = PromptPopUp(master=self.master, title=title_txt, briefing=instructions, entries_txt=askfor, entries_val=_defvals_, width=400, height=565) pop.wait_window() if self.master._aux_ <> []: _advanced_ = self.master._aux_ _entries_ = [ 'int', '', '', 'float', 'float', 'float', '', 'float', 'float::', 'int', 'int', '', '', [list, '-', 'NVE', 'NVT', 'NPT', 'R'], 'float' ] _flag_ = min( check_vars(_advanced_, _entries_, 'Advanced settings not saved!')) if _flag_: self._container_['advanced'][0] = _advanced_ print_dec_g('Advanced settings saved') self.fcb.config(bg='gray86') #, width = 145)
def further_config_script( self ): ''' Section for advaced settings ''' pop_wrg_1('Advanced settings!\nChanging these parameters could result' +' in a different simulation than the base one') defvals = [] title_txt = ' '*3+'+ Simulation Parameters' instructions = 'Input further simulation parameters' askfor = ['Thermo output every [#ts]', 'Atom mapping', 'Pairwise interactions', "L-J/Buck rcutoff ["+u'\u00c5'+"]", "Coulomb rcutoff ["+u'\u00c5'+"]", "Neighbor skin distance ["+u'\u00c5'+"]", 'Long-range solver', 'Long-range relative error', 'L-J interaction 1-2:1-3:1-4', 'Coul interaction 1-2:1-3:1-4', 'Neighbor delay [#ts]', 'Neighbor update [#ts]', 'Pressure control', 'Force mixing rule', 'Velocity creation Temp [K]', 'Energy minimization tolerance', 'Simulation order', '---', 'Shake tolerance', 'Shake bonds [b#]', 'Shake angles [a#]', ] _pair_style_ = ['lj/cut/coul/long','lj/cut/coul/cut', 'lj/cut', 'lj/charmm/coul/long', 'buck/coul/long', 'buck', 'buck/coul/cut', #'lj/cut/tip4p/cut', 'lj/cut/tip4p/long', #'lj/gromacs', 'lj/gromacs/coul/gromacs', #, 'none', 'zero'] if self._convertdata_ <> None: buckorlj = int( self._convertdata_['defaults'][0]) if buckorlj == 1: _pair_style_ = _pair_style_[ :3] + [_pair_style_[ -1]] else: _pair_style_ = _pair_style_[ 3:] _kspace_ = ['pppm', 'pppm/cg', 'ewald', 'pppm/disp', 'ewald/disp', #'pppm/tip4p', 'pppm/disp/tip4p' ] _comb_rule_ = ['No','geometric', 'arithmetic', 'sixthpower'] # ['advanced'][1] in case of drop down lists, to show the other cases self._container_['advanced'][1] = [ '', ['array', 'hash'], _pair_style_, '','','', _kspace_, '', '', '', '', '', ['aniso', 'iso', 'tri'], _comb_rule_, '','','', '', '', '' ] _defvals_ = [] for _ad_ in range(len(self._container_['advanced'][0])): if self._container_['advanced'][1][_ad_] <> '': _def_ = self._container_['advanced'][0][_ad_] _dfli_ = self._container_['advanced'][1][_ad_] _defvals_.append([ _def_, _dfli_]) else: _defvals_.append(self._container_['advanced'][0][_ad_]) self.fcb.config(bg = 'gray70')#, width = 155) #cyan') self.master._aux_ = [] pop = PromptPopUp(master = self.master, title = title_txt, briefing = instructions, entries_txt = askfor, entries_val = _defvals_ , width = 400, height = 665 ) pop.wait_window() _, bnty_len, anty_len = self.check_datafile() print bnty_len, anty_len if self.master._aux_ <> []: _advanced_ = self.master._aux_ _entries_ = [ 'int', '', '', 'float', 'float', 'float', '', 'float', ['<float::<', 0.0, 1.0],['<float::<', 0.0, 1.0], 'int', 'int', '', '', 'float', 'float',[list, '-','NVE','NVT','NPT','R','M'] ,'float', ['<int-x-int<:0', 1, bnty_len], ['<int-x-int<:0', 1, anty_len] ] _flag_ = min( check_vars( _advanced_, _entries_, 'Advanced settings not saved!')) if _flag_: self._container_['advanced'][0] = _advanced_ print_dec_g('Advanced settings saved') self.fcb.config(bg = 'gray86')#, width = 145)