- start(cores=None, version=None, port=0)#
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') model.solve() model.save() client.remove(model)
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 chapter “Limitations”.
Clientinstance. 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.
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
versioncan be selected if several are installed, for example
version='6.0'. Otherwise the latest version is used.
portcan be specified if client–server mode is used. If omitted, the server chooses a random free port.