model
Model object methods that set up basic parts of a model object such as the model history and saving model files.
Syntax
model is a model object that you can create, for example, using ModelUtil.create(<tag>).
model.baseSystem(<system>): The baseSystem methods sets the unit system for the entire model to the given system. The default is the SI system, which has the tag SI. Other supported unit systems are bft (British engineering units), cgs, mpa, emu, esu, fps, ips, and psi.
model.clearThumbnail(): The clearThumbnail method clears the model thumbnail image.
model.dateModified(): The dateModified method returns the modification date of the model.
model.disableUpdates(): The disableUpdates method returns the current status of the disable state for the model object.
model.disableUpdates(boolean) Temporarily disables and re-enables the update of variables in entities that automatically generates other entities (for example, physics or coordSystem). Disable updates to speed up the evaluation of long execution sequences. Leaving this flag disabled can cause strange side effects during modeling. For example, some parameter values in a feature of a physics interface might not be valid until an update has been made. The model inputs are such parameters, which end with the suffix _src. Trying to set a value to any of these parameters with updates disabled might give an error message. Other effects are that the generated variables are unknown to the unit evaluator and equation view readings can be incomplete. When the disabled state goes from true to false, the program performs a full update of the variables, so the model is in a fully functional state.
model.fontFamily(<family>): The fontFamily method sets the font family to be used in plots. The font default is always available. If using Windows, most system fonts can also be used.
model.fontSize(<size>): The fontSize method sets the font size to be used in plots.
model.getComsolVersion(): The getComsolVersion method returns the COMSOL Multiphysics version used to save the model or the current version if the model has never been saved. There is also a ModelUtil.getComsolVersion() method, which returns the current version as a string.
model.getFilePath() returns the absolute path of the model or an empty string if the model has not been saved.
model.getLastComputationTime(string time_format): The getLastComputationTime method returns the last computation time for the model or application as a string. Use model.getLastComputationTime() to get the time measured in ms, which you can then use as an input to model.setLastComputationTime. Other supported time formats are "hr:min:sec", "h:min:s", and "detailed", which returns the time in seconds and also includes more readable units for longer times.
model.getUsedProducts(): The getUsedProducts method returns the products that this model uses.
model.hist().complete(bool) enables or disables history logging for methods where the arguments typically are very large objects.
model.hist().isComplete() returns true if history logging is enabled for methods where the arguments typically are very large objects.
model.hist().disable() Disables logging of top-level API calls to the history. Use this method sparingly; the normal state is that the history is logged.
model.hist().enable() Removes the most recent disabling of top-level API calls to the history. Calling enable() can be viewed as removing an entry from a stack of disable records; logging only occurs if the stack is empty.
model.isReadOnly(): The isReadOnly method returns whether the file where the model is saved is read-only and cannot be overwritten or not. The file can be read-only for two reasons:
If the model has not been saved, this method returns false.
model.lastModifiedBy(): The lastModifiedBy method returns the last user to modify the model.
model.modelPath(<path>): The modelPath method sets the model path. The model path is used for reading files required by the model, if no path is provided to the file. <path> is a list of directories separated by semicolon. When reading an external file, COMSOL Multiphysics attempts to find a file in the following locations:
1
The absolute path as given in the filename. If the path given in the filename is relative, it is resolved relative to the following directories.
2
3
4
5
The directories defined by model.modelPath (ordered and semicolon separated).
6
The directories in the cs.path setting (ordered and semicolon separated).
7
The current directory, which is given by the Java system property user.dir and is the directory where you launch COMSOL Multiphysics, unless you have changed the value of user.dir.
The model directory is used for saving and exporting files if you do not provide an absolute path to the file.
model.modelPath() returns the path <path> set in a call to model.modelPath(<path>).
model.resetHist(): the resetHist method rebuilds the model from scratch to generate a compacted model’s Java- or M-file history (that is, creating a compact history). If the model has errors, or has invalid property values, the method fails and the old history is kept.
model.save(<filename>). The save method saves the model as a multiphysics model file in <filename>. If you do not provide a path, the model is saved in the directory from where you have launched COMSOL Multiphysics.
model.save(<filename>,<type>) saves the multiphysics model in <filename>. If the type is java, a model file for use with Java® is saved. If the type is m, this command saves a model file as an M-file for use with the LiveLink™ for MATLAB®. If the type is vba, this command saves a model file as a VBA-file for use with VBA (Visual Basic for Applications) in Microsoft Excel®.
model.save(<path>,<saveCopy>) saves a copy of the model, if the Boolean argument <saveCopy> is true. If it is set to false, this call results in a normal save operation. When saving as a copy, the location of that copy is not remembered, so the previous location for saving models is retained.
model.setLastComputationTime(long time): The setLastComputatonTime method sets the last computation time for the model or application as the measured computation time (in ms) that you provide as the input.
model.setThumbnail(<image_filename>): The setThumbnail method imports the image file at the given path and sets it as the model’s thumbnail image.
See Also
model.modelNode(), model.unitSystem()