Пример #1
0
def runtests(tests, args):
	for t in tests:
		tid = test.id(t)
		if not tid:
			continue
		try:
			targs = list(args)
			if test.run(t, tid, targs):
				print("OK     : "+test.info(t)+" ["+tid+"]");
			else:
				print("FAIL   : "+test.info(t)+" ["+tid+"]");
		except:
			print("EXCEPTION while running test with ID: "+tid);
			raise
			return 1
	return 0
Пример #2
0
    def sys(self, testdotout):
        '''
        Gather thermodynamic data from the out file.

        inputs:
            self = The object reference
            testdotout = The name of the out file
        '''

        try:
            self.file_dep
        except Exception:

            message = 'Need to specify input file first.'
            raise ValueError(message)

        file_system = os.path.join(self.path, testdotout)  # Output file
        self.file_system = file_system

        # Thermodynamic data from test.out file
        self.dfsys = test.info(file_system)

        self.dfsys['time'] = self.dfsys['Step'] * self.timestep

        # Use data at and after start of cooling
        condition = self.dfsys['Step'] >= self.hold1
        dfcool = self.dfsys[condition]

        return dfcool
Пример #3
0
def main():
	# Parse arguments
	if len(sys.argv) < 2:
		print_help()
		return 1
	action = sys.argv[1]

	if action == "help":
		if len(sys.argv) > 2:
			print_help(sys.argv[2])
		else:
			print_help()
		return 0
	elif action == "list":
		for t in test.all_tests():
			print(t+" - "+test.info(t))
	elif action == "run":
		args = []
		tests = [sys.argv[2]]
		if len(sys.argv) > 3:
			args = sys.argv[3:]
		return runtests(tests, args)
	elif action == "all":
		args = []
		tests = test.all_tests()
		if len(sys.argv) > 2:
			args = sys.argv[2:]
		return runtests(tests, args)
	elif action == "clear":
		test.cleanup()
		if len(sys.argv) > 2 and sys.argv[2] == "--cache":
			cache.clear()
	else:
		print("Unkown command "+action)
		return 1
	return 0
Пример #4
0
    def __init__(self, path):
        '''
        Load all data needed from a job for analysis.
        '''

        # The location of the job
        self.path = path

        # Save path for plots
        self.plotpath = os.path.join(self.path, 'analysis_plots')

        print('Analysis for: ' + path)

        # The name of important files for each job
        trajdotlammpstrj = 'traj.lammpstrj'
        testdotout = 'test.out'
        depdotin = 'dep.in'

        # The name of saving directories
        self.datadirname = 'analysis_data'
        self.plotdirname = 'analysis_plots'

        # Location of files
        file_system = os.path.join(path, testdotout)  # Output file
        file_trajs = os.path.join(path, trajdotlammpstrj)  # Trajectories
        file_dep = os.path.join(path, depdotin)  # Input file

        # Important paramters from the input file
        depparams = dep.info(file_dep)

        # Information from traj.lammpstrj file
        self.dftraj, counts = traj.info(file_trajs)

        # Thermodynamic data from test.out file
        self.dfsys = test.info(file_system)

        self.timestep = depparams['timestep']
        self.hold1 = depparams['hold1']
        self.hold2 = depparams['hold2']
        self.hold3 = depparams['hold3']
        self.increment = depparams['increment']
        self.iterations = depparams['iterations']
        self.deltatemp = depparams['deltatemp']
        self.elements = depparams['elements']

        # Add the times for each dataframe
        self.dfsys['time'] = self.dfsys['Step'] * self.timestep
        self.dftraj['time'] = self.dftraj['Step'] * self.timestep

        # Element counts from actual element
        self.natoms = 0  # Count the total number of atoms
        elements = {}
        for key, count in counts.items():
            self.natoms += count

            element = mg.Element(self.elements[key])
            atomicradii = element.atomic_radius  # in Am
            atomicvol = volume_sphere(atomicradii)  # in Am^3

            elements[self.elements[key]] = {
                'counts': count,
                'radius': atomicradii,
                'volume': atomicvol,
            }

        dfelprops = pd.DataFrame(elements).T

        self.dfelprops = dfelprops  # The properties of elements

        self.calculations = ['system', 'box']  # The calculations done
#!/usr/bin/env python
# -*- coding: UTF-8 -*-

from test import info
import test
info(test)
info(test, 12)
info(test, collapse=0)
info(spacing=15, object=test)
from test import info
import __builtin__
info(__builtin__, 20)
Пример #7
0
from multiprocessing import Process
import test as t
import os

def info(title):
    print(title)
    print("module name : ", __name__)
    print("parent process : ", os.getppid())
    print("process id : ", os.getpid())

def f(name):
    info("function f")
    print("hello", name)


if __name__ == "__main__":
    t.info("main line")
    for i in range(0, 2):
        p = Process(target = t.f, args = ("bob", ))
        p.start()
        p.join()
#!/usr/bin/env python
# -*- coding: UTF-8 -*-

from test import info
li = []
info(li)