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.


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

Depending on the platform, this may either be a stand-alone client (on Windows) or a thin client connected to a server running locally (on Linux and macOS). The reason for this disparity is that, while stand-alone clients are more lightweight and start up much faster, support for this mode of operation is limited on Unix-like operating systems, and thus not the default. Find more details in documentation chapter “Limitations”.

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

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='5.3a'. 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.