OMFrontend.jl
OMFrontend is the Julia port of the OpenModelica frontend. It parses Modelica source, lowers it through SCode, and produces the flat model (FLAT_MODEL, printable as flat Modelica) consumed by OMBackend.jl and the wider OM.jl toolchain.
How OMFrontend works
OMFrontend translates a Modelica class into a flat model: one list of variables and one of equations, with the component hierarchy, inheritance, modifiers and connections resolved. It does this in five steps.
- Parse. OpenModelicaParser.jl reads the Modelica text (a file, a string, a library) into a syntax tree (
OpenModelicaParser.Absyn). - SCode. The syntax tree becomes SCode (
OMFrontend.SCode): classes, their elements and modifiers, in a simpler form. Libraries are kept in this form in a cache, so the Modelica Standard Library is parsed once. - Instantiate. The class is expanded into a tree of instances: names are looked up,
extendsclauses are merged, and modifiers are applied to the components they change. - Type and flatten. Every expression gets its type and dimensions, structural parameters are evaluated,
connectequations become equality and sum-to-zero equations, and arrays are expanded into scalars. - Flat model. The result is a
FLAT_MODELwith the functions it calls. It prints as flat Modelica, OMBackend.jl turns it into a simulation, andcheckcounts its equations and variables.
instantiate runs all five steps. classNames, source, description and documentation read the classes after step 2 without translating them.
Installation
using Pkg
Pkg.add("OMFrontend")Versions from 4.0.0 on are registered in the General registry. The versions before 4.0.0 are only in the OpenModelicaRegistry. If Pkg.add does not find the package, or you need a version before 4.0.0, add that registry once and install again:
using Pkg
Pkg.Registry.add("General")
Pkg.Registry.add(Pkg.RegistrySpec(url = "https://github.com/OpenModelica/OpenModelicaRegistry.git"))
Pkg.add("OMFrontend")Quick example
using OMFrontend
fm = OMFrontend.instantiate("MyModel"; file = "MyModel.mo")
print(fm) # flat ModelicaSee Getting started for a longer walk-through and the API reference for the full list of public entry points.
Project layout
| Path | Purpose |
|---|---|
src/OMFrontend.jl | The module OMFrontend: the public API. |
src/Frontend/ | The module Frontend (Frontend.jl): instantiation, typing, flattening. |
src/SCode/ | SCode, Absyn -> SCode lowering, SCode helpers. |
src/Absyn/ | Absyn helpers and traversals. |
src/Util/ | Flags, errors, hash maps, AVL trees, macros. |
src/API/ | GUI API, component graphics, command line, display. |
src/Precompilation/ | The precompile workload and statements. |
Index
OMFrontend.ListUtilOMFrontend.CheckResultOMFrontend.FlatModelicaOMFrontend.GUI_API.DiagramConnectionOMFrontend.GUI_API.DiagramModelOMFrontend.GUI_API.DiagramNodeOMFrontend.GUI_API.ModelSessionOMFrontend.GUI_API.OperationResultOMFrontend.GUI_API.SaveResultOMFrontend.GUI_API.SourceSpanOMFrontend.GUI_API.TextPatchOMFrontend.GUI_API.ValidationResultOMFrontend.ListUtil.TypedListOMFrontend.ModelicaErrorOMFrontend.ArrayUtil.allOMFrontend.ArrayUtil.anyOMFrontend.ArrayUtil.appendListOMFrontend.ArrayUtil.appendList!OMFrontend.ArrayUtil.appendToElementOMFrontend.ArrayUtil.arrayListsEmptyOMFrontend.ArrayUtil.compareOMFrontend.ArrayUtil.consToElementOMFrontend.ArrayUtil.copyOMFrontend.ArrayUtil.copyNOMFrontend.ArrayUtil.copyRangeOMFrontend.ArrayUtil.createIntRangeOMFrontend.ArrayUtil.existOMFrontend.ArrayUtil.expandOMFrontend.ArrayUtil.expandOnDemandOMFrontend.ArrayUtil.expandToSizeOMFrontend.ArrayUtil.fillOMFrontend.ArrayUtil.foldOMFrontend.ArrayUtil.fold1OMFrontend.ArrayUtil.fold2OMFrontend.ArrayUtil.fold3OMFrontend.ArrayUtil.fold4OMFrontend.ArrayUtil.fold5OMFrontend.ArrayUtil.fold6OMFrontend.ArrayUtil.foldIndexOMFrontend.ArrayUtil.generateOMFrontend.ArrayUtil.getIndexFirstOMFrontend.ArrayUtil.getMemberOnTrueOMFrontend.ArrayUtil.getRangeOMFrontend.ArrayUtil.isEqualOMFrontend.ArrayUtil.isEqualOnTrueOMFrontend.ArrayUtil.mapOMFrontend.ArrayUtil.map0OMFrontend.ArrayUtil.map1OMFrontend.ArrayUtil.map1FoldOMFrontend.ArrayUtil.mapBoolAndOMFrontend.ArrayUtil.mapFoldOMFrontend.ArrayUtil.mapFoldSOOMFrontend.ArrayUtil.mapIndicesOMFrontend.ArrayUtil.mapIndices!OMFrontend.ArrayUtil.mapListOMFrontend.ArrayUtil.mapNoCopyOMFrontend.ArrayUtil.mapNoCopy_1OMFrontend.ArrayUtil.partitionOMFrontend.ArrayUtil.positionOMFrontend.ArrayUtil.reduceOMFrontend.ArrayUtil.removeOnTrueOMFrontend.ArrayUtil.replaceAtWithFillOMFrontend.ArrayUtil.reverseOMFrontend.ArrayUtil.selectOMFrontend.ArrayUtil.setRangeOMFrontend.ArrayUtil.splitOMFrontend.ArrayUtil.threadMapOMFrontend.ArrayUtil.toStringOMFrontend.ArrayUtil.transposeOMFrontend.ArrayUtil.transposeArrayOMFrontend.ArrayUtil.updateIndexFirstOMFrontend.ArrayUtil.updatewithArrayIndexFirstOMFrontend.GUI_API.compileModelOMFrontend.GUI_API.createConnectionOMFrontend.GUI_API.deleteConnectionOMFrontend.GUI_API.exportFlatModelicaOMFrontend.GUI_API.getDiagramOMFrontend.GUI_API.loadModelOMFrontend.GUI_API.saveModelOMFrontend.GUI_API.setExecutionDelegates!OMFrontend.GUI_API.simulateModelOMFrontend.GUI_API.updateComponentPlacementOMFrontend.GUI_API.updateConnectionAnnotationOMFrontend.GUI_API.validateModelOMFrontend.ListUtil._copyOntoOMFrontend.ListUtil._fromVectorOMFrontend.ListUtil._normOMFrontend.ListUtil._reverseOntoOMFrontend.ListUtil._reverseTypedOMFrontend.ListUtil._typedOMFrontend.ListUtil._unionAddOMFrontend.ListUtil._vectorOMFrontend.ListUtil.allOMFrontend.ListUtil.append_reverseOMFrontend.ListUtil.applyAndFoldOMFrontend.ListUtil.consOnTrueOMFrontend.ListUtil.deleteMemberOnTrueOMFrontend.ListUtil.existOMFrontend.ListUtil.exist1OMFrontend.ListUtil.fillOMFrontend.ListUtil.filterOnTrueOMFrontend.ListUtil.findOMFrontend.ListUtil.find1OMFrontend.ListUtil.findOptionOMFrontend.ListUtil.firstNOMFrontend.ListUtil.flattenOMFrontend.ListUtil.flattenReverseOMFrontend.ListUtil.foldOMFrontend.ListUtil.fold1OMFrontend.ListUtil.foldList1OMFrontend.ListUtil.foldrOMFrontend.ListUtil.getMemberOnTrueOMFrontend.ListUtil.hasOneElementOMFrontend.ListUtil.isEqualOnTrueOMFrontend.ListUtil.isMemberOnTrueOMFrontend.ListUtil.lastOMFrontend.ListUtil.lastNOMFrontend.ListUtil.mapOMFrontend.ListUtil.map1OMFrontend.ListUtil.map1FoldOMFrontend.ListUtil.map1_0OMFrontend.ListUtil.map1_2OMFrontend.ListUtil.map2OMFrontend.ListUtil.map2FoldCheckReferenceEqOMFrontend.ListUtil.map2ListOMFrontend.ListUtil.map2OptionOMFrontend.ListUtil.map3OMFrontend.ListUtil.mapAllValueBoolOMFrontend.ListUtil.mapFlatOMFrontend.ListUtil.mapFoldOMFrontend.ListUtil.mapFoldSOOMFrontend.ListUtil.mapListOMFrontend.ListUtil.mapMapOMFrontend.ListUtil.partitionOMFrontend.ListUtil.positionOnTrueOMFrontend.ListUtil.reduceOMFrontend.ListUtil.replaceOnTrueOMFrontend.ListUtil.restOMFrontend.ListUtil.setOMFrontend.ListUtil.sortOMFrontend.ListUtil.sortedUniqueOMFrontend.ListUtil.splitOMFrontend.ListUtil.splitLastOMFrontend.ListUtil.splitOnTrueOMFrontend.ListUtil.splitrOMFrontend.ListUtil.stripFirstOMFrontend.ListUtil.stripNOMFrontend.ListUtil.threadMapAllValueOMFrontend.ListUtil.threadTupleOMFrontend.ListUtil.toStringOMFrontend.ListUtil.trimOMFrontend.ListUtil.unionOMFrontend.ListUtil.unionEltOnTrueOMFrontend.ListUtil.unionOnTrueOMFrontend.ListUtil.uniqueOnTrueOMFrontend.checkOMFrontend.classNamesOMFrontend.componentGraphicsOMFrontend.debug!OMFrontend.descriptionOMFrontend.disableDumpDebugOMFrontend.documentationOMFrontend.enableDumpDebugOMFrontend.exportJSONOMFrontend.exportSCodeRepresentationToFileOMFrontend.flatModelicaOMFrontend.flattenModelOMFrontend.flattenModelWithLibrariesOMFrontend.flattenModelWithMSLOMFrontend.installLibraryOMFrontend.instantiateOMFrontend.instantiateSCodeToFMOMFrontend.julia_mainOMFrontend.librariesOMFrontend.loadBundledMSLOMFrontend.loadInstalledLibraryOMFrontend.loadLibraryOMFrontend.loadMSLOMFrontend.loadPackageDirectoryOMFrontend.parametersOMFrontend.parseFileOMFrontend.removeQuotesFromFlatModelicaOMFrontend.setFlagsOMFrontend.sourceOMFrontend.toFlatModelicaOMFrontend.toStringOMFrontend.translateToSCodeOMFrontend.variables