Пример #1
0
 def process_machine_settings(self, mset):
     if 'machine_info' in mset:
         machine_info = mset.machine_info
         if isinstance(machine_info, dict) or isinstance(machine_info, obj):
             for machine_name, minfo in machine_info.iteritems():
                 mname = machine_name.lower()
                 if Machine.exists(mname):
                     machine = Machine.get(mname)
                     machine.incorporate_user_info(minfo)
                 else:
                     self.error(
                         'machine {0} is unknown\n  cannot set machine_info'
                         .format(machine_name))
                 #end if
             #end for
         else:
             self.error(
                 'machine_info must be a dict or obj\n  you provided type '
                 + machine_info.__class__.__name__)
         #end if
     #end if
     if 'machine' in mset:
         machine_name = mset.machine
         if not Machine.exists(machine_name):
             self.error('machine {0} is unknown'.format(machine_name))
         #end if
         Job.machine = machine_name
         ProjectManager.machine = Machine.get(machine_name)
         if 'account' in mset:
             account = mset.account
             if not isinstance(account, str):
                 self.error(
                     'account for {0} must be a string\n  you provided: {1}'
                     .format(machine_name, account))
             #end if
             ProjectManager.machine.account = account
         #end if
         if 'machine_mode' in mset:
             machine_mode = mset.machine_mode
             if machine_mode in Machine.modes:
                 machine_mode = Machine.modes[machine_mode]
             #end if
             if machine_mode == Machine.modes.interactive:
                 if ProjectManager.machine == None:
                     ProjectManager.class_error(
                         'no machine specified for interactive mode')
                 #end if
                 if not isinstance(ProjectManager.machine, Supercomputer):
                     self.error(
                         'interactive mode is not supported for machine type '
                         + ProjectManager.machine.__class__.__name__)
                 #end if
                 if not 'interactive_cores' in mset:
                     self.error(
                         'interactive mode requested, but interactive_cores not set'
                     )
                 #end if
                 ProjectManager.machine = ProjectManager.machine.interactive_representation(
                     mset.interactive_cores)
                 Job.machine = ProjectManager.machine.name
Пример #2
0
 def process_machine_settings(self,mset):
     if 'machine_info' in mset:
         machine_info = mset.machine_info
         if isinstance(machine_info,dict) or isinstance(machine_info,obj):
             for machine_name,minfo in machine_info.iteritems():
                 mname = machine_name.lower()
                 if Machine.exists(mname):
                     machine = Machine.get(mname)
                     machine.incorporate_user_info(minfo)
                 else:
                     self.error('machine {0} is unknown\n  cannot set machine_info'.format(machine_name))
                 #end if
             #end for
         else:
             self.error('machine_info must be a dict or obj\n  you provided type '+machine_info.__class__.__name__)
         #end if
     #end if
     if 'machine' in mset:
         machine_name = mset.machine
         if not Machine.exists(machine_name):
             self.error('machine {0} is unknown'.format(machine_name))
         #end if
         Job.machine = machine_name
         ProjectManager.machine = Machine.get(machine_name)
         if 'account' in mset:
             account = mset.account
             if not isinstance(account,str):
                 self.error('account for {0} must be a string\n  you provided: {1}'.format(machine_name,account))
             #end if
             ProjectManager.machine.account = account
         #end if
         if 'machine_mode' in mset:
             machine_mode = mset.machine_mode
             if machine_mode in Machine.modes:
                 machine_mode = Machine.modes[machine_mode]
             #end if
             if machine_mode==Machine.modes.interactive:
                 if ProjectManager.machine==None:
                     ProjectManager.class_error('no machine specified for interactive mode')
                 #end if
                 if not isinstance(ProjectManager.machine,Supercomputer):
                     self.error('interactive mode is not supported for machine type '+ProjectManager.machine.__class__.__name__)
                 #end if
                 if not 'interactive_cores' in mset:
                     self.error('interactive mode requested, but interactive_cores not set')
                 #end if
                 ProjectManager.machine = ProjectManager.machine.interactive_representation(mset.interactive_cores)
Пример #3
0
    def __call__(self,**kwargs):

        # guard against invalid settings
        not_allowed = set(kwargs.keys()) - self.all_vars
        if len(not_allowed)>0:
            self.error('unrecognized variables provided.\n  You provided: '+str(list(not_allowed))+'\n  Allowed variables are: '+str(list(vars)))
        #end if

        # extract settings based on keyword groups
        kw = Settings.kw_set(self.project_vars,kwargs)       # project settings
        gamess_kw = Settings.kw_set(self.gamess_vars,kwargs) # gamess settings
        if len(kwargs)>0:
            self.error('some settings keywords have not been accounted for\nleftover keywords: {0}\nthis is a developer error'.format(sorted(kwargs.keys())))
        #end if

        # transfer project variables to project base class
        for name,value in kw.iteritems():
            Pobj.__dict__[name] = value
        #end for

        # process project manager settings
        if 'debug' in kw and kw.debug:
            Pobj.verbose = True
        #end if
        if 'mode' in kw:
            Pobj.set_mode(kw.mode)
        #end if

        # process machine settings
        if 'machine_info' in kw:
            machine_info = Pobj.machine_info
            del Pobj.machine_info
            if isinstance(machine_info,dict) or isinstance(machine_info,obj):
                for machine_name,minfo in machine_info.iteritems():
                    mname = machine_name.lower()
                    if Machine.exists(mname):
                        machine = Machine.get(mname)
                        machine.incorporate_user_info(minfo)
                    else:
                        self.error('machine {0} is unknown\n  cannot set machine_info'.format(machine_name))
                    #end if
                #end for
            else:
                self.error('machine_info must be a dict or obj\n  you provided type '+machine_info.__class__.__name__)
            #end if
        #end if
        if 'machine' in kw:
            machine_name = kw.machine
            if not Machine.exists(machine_name):
                Pobj.class_error('machine {0} is unknown'.format(machine_name))
            #end if
            Job.machine = machine_name
            ProjectManager.machine = Machine.get(machine_name)
            #del Pobj.machine
            if 'account' in kw:
                account = Pobj.account
                #del Pobj.account
                if not isinstance(account,str):
                    self.error('account for {0} must be a string\n  you provided: {1}'.format(machine_name,account))
                #end if
                ProjectManager.machine.account = account
            #end if
            if 'machine_mode' in kw:
                machine_mode = kw.machine_mode
                if machine_mode in Machine.modes:
                    machine_mode = Machine.modes[machine_mode]
                #end if
                if machine_mode==Machine.modes.interactive:
                    if ProjectManager.machine==None:
                        ProjectManager.class_error('no machine specified for interactive mode')
                    #end if
                    if not isinstance(ProjectManager.machine,Supercomputer):
                        self.error('interactive mode is not supported for machine type '+ProjectManager.machine.__class__.__name__)
                    #end if
                    if not 'interactive_cores' in kw:
                        self.error('interactive mode requested, but interactive_cores not set')
                    #end if
                    ProjectManager.machine = ProjectManager.machine.interactive_representation(Pobj.interactive_cores)
                    del Pobj.interactive_cores
                #end if
                del Pobj.machine_mode
            #end if
        #end if

        # process simulation settings
        if 'local_directory' in kw:
            Pobj.file_locations.append(kw.local_directory)
        #end if
        if 'skip_submit' in kw:
            Pobj.skip_submission = Pobj.skip_submit
            del Pobj.skip_submit
        #end if
        if 'file_locations' in kw:
            fl = kw.file_locations
            if isinstance(fl,str):
                Pobj.file_locations.extend([fl])
            else:
                Pobj.file_locations.extend(list(fl))
            #end if
        #end if
        if not 'pseudo_dir' in kw:
            Pobj.pseudopotentials = Pseudopotentials()
        else:
            pseudo_dir = kw.pseudo_dir
            Pobj.file_locations.append(pseudo_dir)
            if not os.path.exists(pseudo_dir):
                self.error('pseudo_dir "{0}" does not exist'.format(pseudo_dir),trace=False)
            #end if
            files = os.listdir(pseudo_dir)
            ppfiles = []
            for f in files:
                pf = os.path.join(pseudo_dir,f)
                if os.path.isfile(pf):
                    ppfiles.append(pf)
                #end if
            #end for
            Pobj.pseudopotentials = Pseudopotentials(ppfiles)        
        #end if

        # more simulation/project manager settings processing
        mode = Pobj.mode
        modes = Pobj.modes
        if mode==modes.stages:
            stages = Pobj.stages
        elif mode==modes.all:
            stages = list(Pobj.primary_modes)
        else:
            stages = [kw.mode]
        #end if
        allowed_stages = set(Pobj.primary_modes)
        if isinstance(stages,str):
            stages = [stages]
        #end if
        if len(stages)==0:
            stages = list(Pobj.primary_modes)
            #self.error('variable stages must be a list of primary modes.\n  Options are '+str(list(allowed_stages)))
        elif 'all' in stages:
            stages = list(Pobj.primary_modes)
        else:
            forbidden = set(Pobj.stages)-allowed_stages
            if len(forbidden)>0:
                self.error('some stages provided are not primary stages.\n  You provided '+str(list(forbidden))+'\n  Options are '+str(list(allowed_stages)))
            #end if
        #end if
        Pobj.mode = modes.stages
        Pobj.stages     = stages
        Pobj.stages_set = set(Pobj.stages)

        # process gamess settings
        Gamess.settings(**gamess_kw)

        return
Пример #4
0
from pw2qmcpack  import Pw2qmcpack , Pw2qmcpackInput , Pw2qmcpackAnalyzer , generate_pw2qmcpack_input , generate_pw2qmcpack
from wfconvert   import Wfconvert  , WfconvertInput  , WfconvertAnalyzer  , generate_wfconvert_input  , generate_wfconvert
from gamess      import Gamess     , GamessInput     , GamessAnalyzer     , generate_gamess_input     , generate_gamess, FormattedGroup
from convert4qmc import Convert4qmc, Convert4qmcInput, Convert4qmcAnalyzer, generate_convert4qmc_input, generate_convert4qmc
from qmcpack     import Qmcpack    , QmcpackInput    , QmcpackAnalyzer    , generate_qmcpack_input    , generate_qmcpack
from vasp        import Vasp       , VaspInput       , VaspAnalyzer       , generate_vasp_input       , generate_vasp
from qmcpack import loop,linear,cslinear,vmc,dmc
from qmcpack import generate_jastrows,generate_jastrow,generate_jastrow1,generate_jastrow2,generate_jastrow3,generate_opt,generate_opts
from qmcpack import generate_cusp_correction
from auxiliary import *
from debug import *


#set the machine if known, otherwise user will provide
hostmachine = Machine.get_hostname()
if Machine.exists(hostmachine):
    Job.machine = hostmachine
    ProjectManager.machine = Machine.get(hostmachine)
#end if



class Settings(Pobj):
    singleton = None

    project_vars = set([
            'machine','account','generate_only','verbose','debug','mode',
            'local_directory','remote_directory','runs','results','sleep',
            'file_locations','load_images','trace','machine_mode','stages',
            'pseudo_dir','skip_submit','interactive_cores','monitor',
            'status_only','machine_info',
Пример #5
0
from pwscf_postprocessors import Bands, BandsInput, BandsAnalyzer, generate_bands_input, generate_bands
from pwscf_postprocessors import Projwfc, ProjwfcInput, ProjwfcAnalyzer, generate_projwfc_input, generate_projwfc
from pwscf_postprocessors import Cppp, CpppInput, CpppAnalyzer, generate_cppp_input, generate_cppp
from pwscf_postprocessors import Pwexport, PwexportInput, PwexportAnalyzer, generate_pwexport_input, generate_pwexport

from qmcpack import loop, linear, cslinear, vmc, dmc
from qmcpack import generate_jastrows, generate_jastrow, generate_jastrow1, generate_jastrow2, generate_jastrow3, generate_opt, generate_opts
from qmcpack import generate_cusp_correction

from qmcpack_workflows import qmcpack_workflow

from debug import *

#set the machine if known, otherwise user will provide
hostmachine = Machine.get_hostname()
if Machine.exists(hostmachine):
    Job.machine = hostmachine
    ProjectManager.machine = Machine.get(hostmachine)
#end if


class Settings(NexusCore):
    singleton = None

    machine_vars = set('''
        machine         account         machine_info    interactive_cores
        machine_mode
        '''.split())

    core_assign_vars = set('''
        status_only     generate_only   runs            results 
Пример #6
0
    def __call__(self,**kwargs):
        vars = set(['machine','account','generate_only','verbose','debug','mode',
                    'local_directory','remote_directory','runs','results','sleep',
                    'file_locations','load_images','trace','machine_mode','stages',
                    'pseudo_dir','skip_submit','interactive_cores','monitor',
                    'status_only','machine_info'])

        keys = set(kwargs.keys())
        not_allowed = keys - vars
        if len(not_allowed)>0:
            Pobj.class_error('unrecognized variables provided.\n  You provided: '+str(list(not_allowed))+'\n  Allowed variables are: '+str(list(vars)),'settings')
        #end if

        for name,value in kwargs.iteritems():
            Pobj.__dict__[name] = value
        #end for

        if 'debug' in kwargs and kwargs['debug']:
            Pobj.verbose = True
        #end if
        if 'mode' in kwargs:
            Pobj.set_mode(kwargs['mode'])
        #end if
        if 'machine_info' in kwargs:
            machine_info = Pobj.machine_info
            del Pobj.machine_info
            if isinstance(machine_info,dict) or isinstance(machine_info,obj):
                for machine_name,minfo in machine_info.iteritems():
                    mname = machine_name.lower()
                    if Machine.exists(mname):
                        machine = Machine.get(mname)
                        machine.incorporate_user_info(minfo)
                    else:
                        Pobj.class_error('machine {0} is unknown\n  cannot set machine_info'.format(machine_name),'settings')
                    #end if
                #end for
            else:
                Pobj.class_error('machine_info must be a dict or obj\n  you provided type '+machine_info.__class__.__name__,'settings')
            #end if
        #end if
        if 'machine' in kwargs:
            machine_name = kwargs['machine']
            if not Machine.exists(machine_name):
                Pobj.class_error('machine {0} is unknown'.format(machine_name),'settings')
            #end if
            Job.machine = machine_name
            ProjectManager.machine = Machine.get(machine_name)
            #del Pobj.machine
            if 'account' in kwargs:
                account = Pobj.account
                #del Pobj.account
                if not isinstance(account,str):
                    Pobj.class_error('account for {0} must be a string\n  you provided: {1}'.format(machine_name,account),'settings')
                #end if
                ProjectManager.machine.account = account
            #end if
            if 'machine_mode' in kwargs:
                machine_mode = kwargs['machine_mode']
                if machine_mode in Machine.modes:
                    machine_mode = Machine.modes[machine_mode]
                #end if
                if machine_mode==Machine.modes.interactive:
                    if ProjectManager.machine==None:
                        ProjectManager.class_error('no machine specified for interactive mode','settings')
                    #end if
                    if not isinstance(ProjectManager.machine,Supercomputer):
                        Pobj.class_error('interactive mode is not supported for machine type '+ProjectManager.machine.__class__.__name__,'settings')
                    #end if
                    if not 'interactive_cores' in kwargs:
                        Pobj.class_error('interactive mode requested, but interactive_cores not set','settings')
                    #end if
                    ProjectManager.machine = ProjectManager.machine.interactive_representation(Pobj.interactive_cores)
                    del Pobj.interactive_cores
                #end if
                del Pobj.machine_mode
            #end if
        #end if
        if 'local_directory' in kwargs:
            Pobj.file_locations.append(kwargs['local_directory'])
        #end if
        if 'skip_submit' in kwargs:
            Pobj.skip_submission = Pobj.skip_submit
            del Pobj.skip_submit
        #end if
        if 'file_locations' in kwargs:
            fl = kwargs['file_locations']
            if isinstance(fl,str):
                Pobj.file_locations.extend([fl])
            else:
                Pobj.file_locations.extend(list(fl))
            #end if
        #end if
        if not 'pseudo_dir' in kwargs:
            Pobj.pseudopotentials = Pseudopotentials()
        else:
            pseudo_dir = kwargs['pseudo_dir']
            Pobj.file_locations.append(pseudo_dir)
            files = os.listdir(pseudo_dir)
            ppfiles = []
            for f in files:
                pf = os.path.join(pseudo_dir,f)
                if os.path.isfile(pf):
                    ppfiles.append(pf)
                #end if
            #end for
            Pobj.pseudopotentials = Pseudopotentials(ppfiles)        
        #end if

        mode = Pobj.mode
        modes = Pobj.modes
        if mode==modes.stages:
            stages = Pobj.stages
        elif mode==modes.all:
            stages = list(Pobj.primary_modes)
        else:
            stages = [kwargs['mode']]
        #end if
        allowed_stages = set(Pobj.primary_modes)
        if isinstance(stages,str):
            stages = [stages]
        #end if
        if len(stages)==0:
            stages = list(Pobj.primary_modes)
            #Pobj.class_error('variable stages must be a list of primary modes.\n  Options are '+str(list(allowed_stages)),'settings')
        elif 'all' in stages:
            stages = list(Pobj.primary_modes)
        else:
            forbidden = set(Pobj.stages)-allowed_stages
            if len(forbidden)>0:
                Pobj.class_error('some stages provided are not primary stages.\n  You provided '+str(list(forbidden))+'\n  Options are '+str(list(allowed_stages)),'settings')
            #end if
        #end if
        Pobj.mode = modes.stages
        Pobj.stages     = stages
        Pobj.stages_set = set(Pobj.stages)

        return
Пример #7
0
    def __call__(self,**kwargs):

        # guard against invalid settings
        not_allowed = set(kwargs.keys()) - self.all_vars
        if len(not_allowed)>0:
            self.error('unrecognized variables provided.\n  You provided: '+str(list(not_allowed))+'\n  Allowed variables are: '+str(list(vars)))
        #end if

        # extract settings based on keyword groups
        kw = Settings.kw_set(self.project_vars,kwargs)       # project settings
        gamess_kw = Settings.kw_set(self.gamess_vars,kwargs) # gamess settings
        if len(kwargs)>0:
            self.error('some settings keywords have not been accounted for\nleftover keywords: {0}\nthis is a developer error'.format(sorted(kwargs.keys())))
        #end if

        # transfer project variables to project base class
        for name,value in kw.iteritems():
            Pobj.__dict__[name] = value
        #end for

        # process project manager settings
        if 'debug' in kw and kw.debug:
            Pobj.verbose = True
        #end if
        if 'mode' in kw:
            Pobj.set_mode(kw.mode)
        #end if

        # process machine settings
        if 'machine_info' in kw:
            machine_info = Pobj.machine_info
            del Pobj.machine_info
            if isinstance(machine_info,dict) or isinstance(machine_info,obj):
                for machine_name,minfo in machine_info.iteritems():
                    mname = machine_name.lower()
                    if Machine.exists(mname):
                        machine = Machine.get(mname)
                        machine.incorporate_user_info(minfo)
                    else:
                        self.error('machine {0} is unknown\n  cannot set machine_info'.format(machine_name))
                    #end if
                #end for
            else:
                self.error('machine_info must be a dict or obj\n  you provided type '+machine_info.__class__.__name__)
            #end if
        #end if
        if 'machine' in kw:
            machine_name = kw.machine
            if not Machine.exists(machine_name):
                Pobj.class_error('machine {0} is unknown'.format(machine_name))
            #end if
            Job.machine = machine_name
            ProjectManager.machine = Machine.get(machine_name)
            #del Pobj.machine
            if 'account' in kw:
                account = Pobj.account
                #del Pobj.account
                if not isinstance(account,str):
                    self.error('account for {0} must be a string\n  you provided: {1}'.format(machine_name,account))
                #end if
                ProjectManager.machine.account = account
            #end if
            if 'machine_mode' in kw:
                machine_mode = kw.machine_mode
                if machine_mode in Machine.modes:
                    machine_mode = Machine.modes[machine_mode]
                #end if
                if machine_mode==Machine.modes.interactive:
                    if ProjectManager.machine==None:
                        ProjectManager.class_error('no machine specified for interactive mode')
                    #end if
                    if not isinstance(ProjectManager.machine,Supercomputer):
                        self.error('interactive mode is not supported for machine type '+ProjectManager.machine.__class__.__name__)
                    #end if
                    if not 'interactive_cores' in kw:
                        self.error('interactive mode requested, but interactive_cores not set')
                    #end if
                    ProjectManager.machine = ProjectManager.machine.interactive_representation(Pobj.interactive_cores)
                    del Pobj.interactive_cores
                #end if
                del Pobj.machine_mode
            #end if
        #end if

        # process simulation settings
        if 'local_directory' in kw:
            Pobj.file_locations.append(kw.local_directory)
        #end if
        if 'skip_submit' in kw:
            Pobj.skip_submission = Pobj.skip_submit
            del Pobj.skip_submit
        #end if
        if 'file_locations' in kw:
            fl = kw.file_locations
            if isinstance(fl,str):
                Pobj.file_locations.extend([fl])
            else:
                Pobj.file_locations.extend(list(fl))
            #end if
        #end if
        if not 'pseudo_dir' in kw:
            Pobj.pseudopotentials = Pseudopotentials()
        else:
            pseudo_dir = kw.pseudo_dir
            Pobj.file_locations.append(pseudo_dir)
            if not os.path.exists(pseudo_dir):
                self.error('pseudo_dir "{0}" does not exist'.format(pseudo_dir),trace=False)
            #end if
            files = os.listdir(pseudo_dir)
            ppfiles = []
            for f in files:
                pf = os.path.join(pseudo_dir,f)
                if os.path.isfile(pf):
                    ppfiles.append(pf)
                #end if
            #end for
            Pobj.pseudopotentials = Pseudopotentials(ppfiles)        
        #end if

        # more simulation/project manager settings processing
        mode = Pobj.mode
        modes = Pobj.modes
        if mode==modes.stages:
            stages = Pobj.stages
        elif mode==modes.all:
            stages = list(Pobj.primary_modes)
        else:
            stages = [kw.mode]
        #end if
        allowed_stages = set(Pobj.primary_modes)
        if isinstance(stages,str):
            stages = [stages]
        #end if
        if len(stages)==0:
            stages = list(Pobj.primary_modes)
            #self.error('variable stages must be a list of primary modes.\n  Options are '+str(list(allowed_stages)))
        elif 'all' in stages:
            stages = list(Pobj.primary_modes)
        else:
            forbidden = set(Pobj.stages)-allowed_stages
            if len(forbidden)>0:
                self.error('some stages provided are not primary stages.\n  You provided '+str(list(forbidden))+'\n  Options are '+str(list(allowed_stages)))
            #end if
        #end if
        Pobj.mode = modes.stages
        Pobj.stages     = stages
        Pobj.stages_set = set(Pobj.stages)

        # process gamess settings
        Gamess.settings(**gamess_kw)

        return