Ejemplo n.º 1
0
def test_start():
    if system() != 'Windows':
        return
    client = mph.start(cores=1)
    assert client.java is not None
    assert client.cores == 1
    with logging_disabled():
        try:
            mph.start()
        except NotImplementedError:
            pass
        try:
            client.disconnect()
        except RuntimeError:
            pass
Ejemplo n.º 2
0
def test_start():
    with logging_disabled():
        try:
            mph.option('session', 'invalid')
            mph.start()
        except ValueError:
            pass
    mph.option('session', 'client-server')
    client = mph.start(cores=1)
    assert client.java is not None
    assert client.cores == 1
    with logging_disabled():
        try:
            mph.start()
        except NotImplementedError:
            pass
Ejemplo n.º 3
0
def test_init():
    global client
    if mph.option('session') == 'platform-dependent':
        mph.option('session', 'client-server')
    client = mph.start(cores=1)
    assert client.java is not None
    assert client.cores == 1
    with logging_disabled():
        try:
            mph.start()
        except NotImplementedError:
            pass
        try:
            mph.Client()
        except NotImplementedError:
            pass
Ejemplo n.º 4
0
def worker(jobs, results):
    """Performs jobs and delivers the results."""
    client = mph.start(cores=1)
    model = client.load('../tests/capacitor.mph')
    while True:
        try:
            d = jobs.get(block=False)
        except Empty:
            break
        model.parameter('d', f'{d} [mm]')
        model.solve('static')
        C = model.evaluate('2*es.intWe/U^2', 'pF')
        results.put((d, C))
Ejemplo n.º 5
0
def setup_module():
    global client, model
    client = mph.start()
    model = models.capacitor()
Ejemplo n.º 6
0
def setup_module():
    global client, model, empty
    client = mph.start()
    model = models.capacitor()
    empty = client.create('empty')
Ejemplo n.º 7
0
    def stop(self):
        """Stops timing the step, displaying the elapsed time."""
        elapsed = now() - self.t0
        print(f'{elapsed:.1f} seconds', flush=True)


########################################
# Main                                 #
########################################

# Display welcome message.
print('Compacting Comsol models in the current folder.')

# Start Comsol client.
print('Running Comsol client on single processor core.')
client = mph.start(cores=1)

# Loop over model files.
timer = Timer()
for file in Path.cwd().glob('*.mph'):

    name = file.relative_to(Path.cwd())
    print(f'{name}:')

    timer.start('Loading')
    try:
        model = client.load(file)
        timer.stop()
    except Exception:
        timer.cancel('Failed.')
        continue
Ejemplo n.º 8
0
"""Exits the Python session right after starting a client."""
__license__ = 'MIT'

import parent # noqa F401
import mph
import sys

client = mph.start()
sys.exit(2)
Ejemplo n.º 9
0
def setup_module():
    global client, model
    client = mph.start()
    model = client.load(file)
Ejemplo n.º 10
0
def test_init():
    global client
    client = mph.start(cores=cores)
    assert client.java is not None
    assert not client.models()
    assert client.cores == cores