start

start(cores=None, version=None, port=0)[source]

Starts a local Comsol session.

This convenience function provides for the typical use case of running a Comsol session on the local machine, i.e. not have a client connect to a remote server elsewhere on the network.

Example usage:

import mph
client = mph.start(cores=1)
model = client.load('model.mph')
model.solve()
model.save()
client.remove(model)

Returns a Client instance. Only one client can be instantiated at a time. Subsequent calls to start() will return the client instance created in the first call. In order to work around this limitation of the Comsol API, separate Python processes have to be started. Refer to section “Multiple processes” for guidance.

By default, we communicate with the Comsol compute back-end in client–server mode. To run a stand-alone client, set mph.option('session',    'stand-alone') up front. A stand-alone client starts up faster and reduces the call overhead to the Comsol API. However, it only works out of the box on Windows, but not Linux and macOS. Find more details in section “Platform differences”.

The number of cores (threads) the Comsol instance uses can be restricted by specifying a number. Otherwise all available cores will be used.

A specific Comsol version can be selected if several are installed, for example version='6.0'. Otherwise the latest version is used.

The server port can be specified if client–server mode is used. If omitted, the server chooses a random free port.