A recurring problem as my ModelingToolkit [MTK] models get more complex… I am running a MTK model developed for my students, i.e., the model is complete in that it runs.
I now have to create a problem document for the students, where I provide model parameters, initial values for unknowns, etc. in (LaTeX) tables.
To illustrate my “problem”, as part of the model “class” I create using macro @mtkmodel
, I have the following section:
# Model parameters
@parameters begin
# Constant
R = 8.314, [description = "Ideal gas constant, J/mol.K"]
F = 9.649e4, [description = "Faraday constant, C/mol"]
p_o = 1e5, [description = "Standard state pressure, Pa"]
# Parameters
# -- general parameters
The list of parameters is much longer than what is shown here, copying and pasting into LaTeX is error-prone, and perhaps I’m lazy. But …
- Is there some way to parse the model that I make by
@mtkmodel
and convert parameters (and variables?) into tables with, say, parameter names in the first column, values in the second column, and the description text string as comments in the third column?
I have not started to experiment with assigning units to parameters, variables, etc. If that is done, it would, of course, be even better to associate the units directly with the parameter values (e.g., using the \unittwo command).
OK – I know this is a “luxury” problem, but some say that lazyness is one of the driving forces of progress . One possibility would perhaps be to convert the parameters into a dataframe, and then use PrettyTables to produce the LaTeX code. Or, it could probably also be done directly.
- Perhaps there already is functionality for this?