General Commands > About General Commands > model

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>) 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.dateModified() returns the modification date of the model.
model.disableUpdates() 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>) 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>) sets the font size to be used in plots.
model.getComsolVersion() returns the COMSOL version used to save the model or the current version if the model has never been saved.
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) 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() 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.lastModifiedBy() returns the last user to modify the model.
model.modelPath(<path>) 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 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 current user directory.
2
3
The directories defined by modelPath model, if any.
4
The directories in the cs.path setting (ordered and semicolon separated).
5
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 model path.
model.resetHist() rebuilds the model from scratch to generate a compacted model’s Java or M-file history. If the model has errors, or has invalid property values, the method fails and the old history is kept.
model.save(<filename>) saves the model as a multiphysics model file in <filename>. The model directory is used if no path is provided.
model.save(<filename>,<type>) saves the multiphysics model in <filename>. If type is java, a model file for use with Java® is saved. If type is m, this command saves a model file as an M-file for use with the LiveLink™ for MATLAB®.
model.setLastComputationTime(long time) sets the last computation time for the model or application as the measured computation time (in ms) that you provide as the input.
See Also
model.modelNode(), model.unitSystem()