Example #1
0
 def extract_data_sub(subfolder, transform_y = lambda y: np.log10(y)):
     base = osio.cwd()
     osio.cd(subfolder)
     X = np.load('xnkl.array.npy')
     y = float(open('jeff2_h.txt', 'r').readline())
     y = transform_y(y)
     osio.cd(base)
     return X, y
from momo import osio, endl, flush

fs = [ 'nN', 'aA', 'cC' ]
mol = 'PEN'

for f in fs:
	osio.cd(f)
	osio >> '../gdma_formchk.sh {mol:s}_{f:s}'.format(mol=mol, f=f)
	osio.cd(-1)
Example #3
0
from momo import osio, endl, flush

fs = ['nN', 'aA', 'cC']
mol = 'PEN'

for f in fs:
    osio.cd(f)
    osio >> '../gdma_formchk.sh {mol:s}_{f:s}'.format(mol=mol, f=f)
    osio.cd(-1)
Example #4
0
        return



# LOAD STRUCTURES
structures = [ 
    soap.tools.setup_structure_ase(c.config_file, c.atoms)
    for c in soap.tools.ase_load_all('in.configs')
]
struct_dict = {}
for struct in structures:
    print struct.label
    struct_dict[struct.label] = struct

# CHANGE TO WORKING DIRECTORY
osio.cd('out.files.hexcomb')

# SELECT STRUCTURE
struct = struct_dict[select_struct_label]



# CREATE NETWORK
hexcomb = SimSpaceNetwork(options)
hexcomb.createHexComb(c=1.4, N=N_network)
hexcomb.createNeighbours(cutoff=1.41)
hexcomb.writeXyz()

root_idx = 2*((2*N_network+1)*2*N_network + N_network)
"""
hexcomb.printInfo()
Example #5
0
target_map = {}
tree = XmlTree('extract.pairs.xml')
pair_tags = tree.DiveForAll('pair')
pair_count = 0
for pair in pair_tags:
    id1 = pair['id1'](int)
    id2 = pair['id2'](int)
    jeff2_h = pair['channel'].GetUnique('jeff2_h')(float)
    if target_map.has_key(id1):
        pass
    else:
        target_map[id1] = {}
    target_map[id1][id2] = jeff2_h

# EXPAND STRUCTURES
osio.cd('frame0')
pair_folders = get_dirs('./', 'pair_')
n_pairs = len(pair_folders)
pair_folders = sorted(
    pair_folders,
    key=lambda f: int(f.split('_')[1]) * n_pairs + int(f.split('_')[2]))

xnkl_list = []
target_list = []
label_list = []
pair_id = 0
for folder in pair_folders:
    pair_id += 1
    # READ XYZ => CONFIG
    osio.cd(folder)
    osio << "Pair-ID %5d ('%s')" % (pair_id, folder) << endl
Example #6
0
osio << "Run ..." << endl
out = osio >> osio.catch >> "ctp_parallel -l -v"
osio >> osio.devnull >> "ctp_run -l -v"
osio.DisconnectFromFile()

ls = osio >> osio.catch >> "ls"
osio << "Result of 'ls':" << endl
for item in ls.split():
    osio << osio.item << item << endl

# DIRECTORY HIKING
osio << osio.mg << "DIRECTORY HIKING" << endl
try:
    osio >> osio.assert_zero >> 'mkdir testdir'
except RuntimeError:
    osio >> 'rm -r testdir'
    osio >> 'mkdir testdir'
osio.cd('/home')
osio.cd(0)
osio.cd('testdir')
osio.cd(-2)
osio.cd(-1)
osio.cd('../')

cwd = osio.pwd()
osio << "Current directory:" << cwd << endl

# EXIT PROTOCOLS
osio << osio.mg << "EXIT PROTOCOLS" << endl
osio.okquit()
Example #7
0
def extract_data(folder, N_train, N_test, regex):
    def extract_data_sub(subfolder, transform_y = lambda y: np.log10(y)):
        base = osio.cwd()
        osio.cd(subfolder)
        X = np.load('xnkl.array.npy')
        y = float(open('jeff2_h.txt', 'r').readline())
        y = transform_y(y)
        osio.cd(base)
        return X, y
    def sort_subfolders(folders):
        return sorted(folders, key = lambda f: int(f.split('_')[1])*len(folders)+int(f.split('_')[2]))

    base = osio.cwd() 
    osio << "Base =" << base << endl
    osio.cd(folder)

    # GET SUBFOLDERS
    subfolders = sort_subfolders(get_dirs('./', regex))
   
    # LIMIT RANGE 
    N = N_train + N_test
    assert N < len(subfolders)
    subfolders = subfolders[:N]
    
    # FIND DESCRIPTOR DIMENSIONS
    dim_x = extract_data_sub(subfolders[0])[0].shape[0]
    osio << "Descriptor dimension =" << dim_x << endl

    # EXTRACT FEATURES & TARGETS
    X_list = np.zeros((N, dim_x))
    y_list = np.zeros((N))
    idx = -1
    for subfolder in subfolders:
        idx += 1
        osio << osio.back << subfolder << flush
        X, y = extract_data_sub(subfolder)
        X_list[idx] = X
        y_list[idx] = y
    osio << endl

    # SPLIT ONTO TRAINING & TEST SET
    X_train = np.zeros((N_train, dim_x))
    y_train = np.zeros((N_train))
    X_test = np.zeros((N_test, dim_x))
    y_test = np.zeros((N_test))


    X_train[0] = X_list[0]
    y_train[0] = y_list[0]
    count_train = 1
    count_test = 0
    for idx in range(1,N):
        if float(count_train)/(count_train+count_test) < float(N_train)/(N):
            X_train[count_train] = X_list[idx]
            y_train[count_train] = y_list[idx]
            count_train += 1
        else:
            X_test[count_test] = X_list[idx]
            y_test[count_test] = y_list[idx]
            count_test += 1
    
    assert count_train == N_train
    assert count_test == N_test

    osio.cd(base)
    return X_train, y_train, X_test, y_test
Example #8
0
osio << "Run ..." << endl
out = osio >> osio.catch >> "ctp_parallel -l -v"
osio >> osio.devnull >> "ctp_run -l -v"
osio.DisconnectFromFile()

ls = osio >> osio.catch >> "ls"
osio << "Result of 'ls':" << endl
for item in ls.split():
    osio << osio.item << item << endl

# DIRECTORY HIKING
osio << osio.mg << "DIRECTORY HIKING" << endl
try:
    osio >> osio.assert_zero >> "mkdir testdir"
except RuntimeError:
    osio >> "rm -r testdir"
    osio >> "mkdir testdir"
osio.cd("/home")
osio.cd(0)
osio.cd("testdir")
osio.cd(-2)
osio.cd(-1)
osio.cd("../")

cwd = osio.pwd()
osio << "Current directory:" << cwd << endl

# EXIT PROTOCOLS
osio << osio.mg << "EXIT PROTOCOLS" << endl
osio.okquit()
    ofs.write(
        """\
Title "{tag:s}"
File {fchk:s}

Multipoles
  Limit 2
  Limit 1 H
  Radius H 0.35
  Punch {tag:s}.mps
Start

Finish
""".format(
            fchk=fchkfile, tag=tag
        )
    )
    ofs.close()


GDMA = "/people/thnfs/homes/poelking/GDMA/gdma-2.2.06/bin/gdma"
dirs = ["nN", "aA", "cC"]
mol = "PEN"

for dir in dirs:
    osio.cd(dir)
    osio << "Directory: '%s'" % dir << endl
    write_gdma_infile("{mol:s}_{dir:s}.fchk".format(mol=mol, dir=dir))
    osio >> "{gdma:s} < gdma.in > gdma.out &".format(gdma=GDMA)
    osio.cd(-1)
Example #10
0
    assert fchkfile[-5:] == '.fchk'
    tag = fchkfile[:-5]
    osio << "File 'gdma.in' in" << osio.cwd() << ":" << fchkfile << endl
    ofs = open('gdma.in', 'w')
    ofs.write('''\
Title "{tag:s}"
File {fchk:s}

Multipoles
  Limit 2
  Limit 1 H
  Radius H 0.35
  Punch {tag:s}.mps
Start

Finish
'''.format(fchk=fchkfile, tag=tag))
    ofs.close()


GDMA = '/people/thnfs/homes/poelking/GDMA/gdma-2.2.06/bin/gdma'
dirs = ['nN', 'aA', 'cC']
mol = 'PEN'

for dir in dirs:
    osio.cd(dir)
    osio << "Directory: '%s'" % dir << endl
    write_gdma_infile('{mol:s}_{dir:s}.fchk'.format(mol=mol, dir=dir))
    osio >> '{gdma:s} < gdma.in > gdma.out &'.format(gdma=GDMA)
    osio.cd(-1)
Example #11
0
# LOAD STRUCTURES
structures = [ 
    soap.tools.setup_structure_ase(c.config_file, c.atoms)
    for c in soap.tools.ase_load_all('in.configs')
]
struct_dict = {}
for struct in structures:
    print struct.label
    struct_dict[struct.label] = struct

# SELECT STRUCTURE
struct = struct_dict[select_struct_label]

# CREATE TREE
osio.cd('out.files')
tree = SimSpaceTree(options)
tree.seed(struct)

N_generations = 2
N_spawn = [3,3]

N_generations = 4
N_spawn = [2,2,2,2]

N_generations = 9
N_spawn = [ 2 for n in range(N_generations) ]
authorize_spawn_fct = lambda joint: joint.node.energy <= 0.0

for n in range(N_generations):
    gen_id = n+1
Example #12
0
import espressopp as sxx
from momo import osio, endl, flush
import mpi4py.MPI as MPI
import os

osio << "Running on %d cores ..." % MPI.COMM_WORLD.size << endl

# COLLECT CONFIG FILES FROM FOLDER
config_file_dir = './configs'
osio.cd(config_file_dir)
config_files = sorted(os.listdir('./'))
config_list = sxx.tools.convert.aseread.AseConfigList(config_files, log=osio)
osio.cd(-1)

# SETUP SYSTEMS FOR CONFIGURATIONS
systems = []
for config in config_list:
    osio << config.atoms << endl
    system = sxx.tools.convert.aseread.setup_sxx_system(config.atoms, config.config_file)
    systems.append(system)

# SET OPTIONS
options = sxx.soap.Options()
options.configureCenters(1., [1,77,119])
options.configureRealBasis(12,9,10.)
options.configureReciprocalBasis(10,7,8.)

b1 = sxx.Real3D(2.,0,0)
b2 = sxx.Real3D(0,2.,0)
b3 = sxx.Real3D(0,0,2.)
options.configureReciprocalLattice(b1, b2, b3)