예제 #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
예제 #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
예제 #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
예제 #4
0
파일: worker_pool.py 프로젝트: max3-2/MPh
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))
예제 #5
0
def setup_module():
    global client, model
    client = mph.start()
    model = models.capacitor()
예제 #6
0
def setup_module():
    global client, model, empty
    client = mph.start()
    model = models.capacitor()
    empty = client.create('empty')
예제 #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
예제 #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)
예제 #9
0
def setup_module():
    global client, model
    client = mph.start()
    model = client.load(file)
예제 #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