Exemplo n.º 1
0
def import_file(file_name):
    base_dir = get_base_dir()
    module_path = os.path.dirname(os.path.join(base_dir, file_name))

    if module_path not in sys.path:
        sys.path.append(module_path)
        remove_path = True
    else:
        remove_path = False

    module_name = os.path.splitext(os.path.basename(file_name))[0]

    conf = __import__(module_name)

    if remove_path:
        sys.path.pop(-1)

    return conf
Exemplo n.º 2
0
def import_file(file_name):
    base_dir = get_base_dir()
    module_path = os.path.dirname(os.path.join(base_dir, file_name))

    if module_path not in sys.path:
        sys.path.append(module_path)
        remove_path = True
    else:
        remove_path = False

    module_name = os.path.splitext(os.path.basename(file_name))[0]

    conf = __import__(module_name)

    if remove_path:
        sys.path.pop(-1)

    return conf
Exemplo n.º 3
0
"""
Input file for a scalar linear elliptic problems.
"""

import numpy as np
import os
from general.base import get_base_dir

base_dir = get_base_dir()

dim = 2
N = 5*np.ones(dim, dtype=np.int32)

materials = {'square': {'inclusions': ['square', 'otherwise'],
                        'positions': [np.zeros(dim), ''],
                        'params': [0.6*np.ones(dim), ''], # size of sides
                        'vals': [11*np.eye(dim), 1.*np.eye(dim)],
                        'Y': np.ones(dim),
                        'order': None,
                        },
             'square_Ga': {'inclusions': ['square', 'otherwise'],
                           'positions': [np.zeros(dim), ''],
                           'params': [0.6*np.ones(dim), ''], # size of sides
                           'vals': [11*np.eye(dim), 1.*np.eye(dim)],
                           'Y': np.ones(dim),
                           'order': 0,
                           'P': N,
                        },
             'square2': {'inclusions': ['square', 'otherwise'],
                         'positions': [np.zeros(dim), ''],
                         'params': [1.2*np.ones(dim), ''], # size of sides
Exemplo n.º 4
0
"""
Input file for a scalar linear elliptic problems.
"""

import numpy as np
import os
from general.base import get_base_dir

base_dir = get_base_dir()
input_dir = os.path.dirname(os.path.abspath(__file__))
file_name = os.path.join(input_dir, 'topologie.txt')


def get_topo():
    topo = np.loadtxt(file_name)
    return topo


topo = get_topo()
P = np.array(topo.shape)  # image resolution
dim = P.size


def get_mat(coord=None):
    topo = get_topo()
    if coord is not None and not (topo.shape == coord.shape[1:]):
        raise ValueError()
    matrix_phase = np.eye(dim)
    inclusion = 11. * np.eye(dim)
    mat_vals = np.einsum('ij...,k...->ijk...', matrix_phase, topo == 0)
    mat_vals += np.einsum('ij...,k...->ijk...', inclusion, topo == 1)