The most common approach to start and connect Excel to a COMSOL Multiphysics server is by opening a model using OpenModel() from the RibbonUtil utilities. However, LiveLink™
for Excel® also provides methods for starting and connecting to a server manually.
Ordinarily you would run StartComsolServer() to start the COMSOL Multiphysics server:
This command will start the COMSOL Multiphysics server in graphics mode when useGraphics is set to
True on the local computer. A port number, which is used for the communication between the COMSOL server and Excel, is automatically assigned by the COMSOL server. The default number is 2036, but if other COMSOL servers are running then a higher number has to be chosen. It also returns a Boolean to indicate if the COMSOL server has started (
True) or failed to start (
False).
To connect Excel to the COMSOL server using the default port number, simply use the command:
where hostname,
portnumber,
login, and
pwd are optional argument that set the connection credential: computer name, the port number the server is listening to, the user name and the password respectively. If you are already connected to a server and try to connect it again, nothing happens and you will remain connected. If however you try connect to a different server, it will disconnect automatically from the first one and connect to the specified one.