API

Heta Compiler CLI

HetaImporter.heta_help — Function
heta_help(command::Union{String, Nothing}=nothing)

Displays help for heta-compiler CLI

Arguments:

  • command: command to display. Default is nothing to display general help
HetaImporter.heta_build — Function
heta_build(
  target_dir::AbstractString;
  declaration::String = "platform",
  units_check::Bool = false,
  log_mode::String = "error",
  log_path::String = "build.log",
  log_level::String = "info",
  debug::Bool = false,
  dist_dir::String = "dist",
  meta_dir::String = "meta",
  source::String = "index.heta",
  type::String = "heta",
  export_format::Union{String, Nothing} = nothing,
)

Builds the models from Heta-based platform

See heta compiler docs for details: https://hetalang.github.io/hetacompiler/cli-references.html#running-heta-build-with-options

Arguments:

  • target_dir : path to the directory where Heta platform is located
  • declaration : filepath to the platform declaration file. Default is "platform"
  • units_check : if set to true units will be checked for the consistency
  • log_mode : log mode. Default is "error"
  • log_path : path to the log file. Default is "build.log"
  • log_level : log level to display. Default is "info"
  • debug : turn on debug mode. Default is false
  • dist_dir : directory path, where to write distributives to. Default is "dist"
  • meta_dir : meta directory path. Default is "meta"
  • source : path to the main heta module. Default is "index.heta"
  • type : type of the source file. Default is "heta"
  • export_format : export the model to the specified format: julia,dynms,{format:SBML,version:L3V1}

Julia File Generation

HetaImporter.build_dynms_file — Function
build_dynms_file(heta_dir; build_dir, kwargs...)

Build a Heta platform and write a DynMS JSON file to joinpath(build_dir, DYNMS_MODEL_DIR, DYNMS_MODEL_NAME).

The returned value is the generated DynMS JSON file path.

Arguments:

  • heta_dir : path to a Heta source directory containing a platform declaration file
  • build_dir : directory path where generated files are written. Default is joinpath(heta_dir, "dist")
  • spaceFilter : filter for namespaces in the Heta model. Can be a string, a vector of symbols, or nothing. Default is nothing
  • kwargs : other arguments supported by heta_build
HetaImporter.build_julia_file — Function
build_julia_file(heta_dir; build_dir, ir_format=:julia, kwargs...)

Build a Heta platform and write a Julia source file to joinpath(build_dir, JULIA_MODEL_DIR, JULIA_MODEL_NAME).

heta-compiler writes Julia code directly. The only supported ir_format is :julia. To construct a native HetaODESystem, use import_heta.

The returned value is the generated Julia file path.

Arguments:

  • heta_dir : path to a Heta source directory containing a platform declaration file
  • ir_format : compiler export format. Only :julia is supported.
  • build_dir : directory path where generated files are written. Default is joinpath(heta_dir, "dist")
  • spaceFilter : filter for namespaces in the Heta model. Can be a string, a vector of symbols, or nothing. Default is nothing
  • kwargs : other arguments supported by heta_build

Advanced: Heta Parsing

Advanced: DynMS Parsing

HetaImporter.parse_dynms — Function
parse_dynms(dynms_json::AbstractString)
parse_dynms(data::AbstractDict)

Parse a DynMS JSON file or already-loaded JSON dictionary into a DynMSModelSet.

The returned specification contains parsed model definitions, Julia expression trees for mathematical expressions, event definitions, and metadata from the DynMS generator.

HetaImporter.parse_dynms_model — Function
parse_dynms_model(model::AbstractDict)

Parse one DynMS model dictionary into a DynMSModel.

This is mainly useful when working with a model entry extracted from a DynMS document. For normal use, prefer parse_dynms.

Heta Import and ODE Construction

HetaImporter.import_heta — Function
import_heta(heta_dir; model_id=nothing, write_to_file=false,
            filename=nothing, kwargs...)

Compile a Heta project, parse it, and lower the selected model to a native HetaODESystem. Remaining keyword arguments are forwarded to parse_heta.

HetaImporter.import_heta_all — Function
import_heta_all(heta_dir; write_to_file=false, output_dir=".", kwargs...)

Compile a Heta project and return every model as an OrderedDict{Symbol,<:HetaODESystem} keyed by model ID. Remaining keyword arguments are forwarded to parse_heta.

When write_to_file=true, readable generated code is written to <output_dir>/<model_id>_ode.jl for each system.

HetaImporter.HetaODESystem — Type
HetaODESystem

Native Julia representation of a parsed Heta ODE model. dynms retains the semantic model for inspection and generated_code contains the fixed, uncompiled Julia functions generated once by build_ode_system.

parameter_index indexes the complete flattened parameter container (tunables, derived, then discretes). discrete_index indexes only the discrete portion and is also used as its parameter-timeseries index.

HetaImporter.HetaParameters — Type
HetaParameters(tunable, nderived, ndiscrete, initialize_parameters!)

Runtime parameter storage used by the native Julia backend. tunable contains the flat values exposed to optimizers, derived contains values recalculated from tunables at the start of a solve, and discrete contains values that callbacks may mutate during integration.

initialize_parameters!(derived, discrete, tunable) is generated with the model. It is called by the constructor and whenever the Tunable portion is replaced. Replacing only the Discrete portion restores values saved during a simulation without reinitializing them.

HetaImporter.build_ode_system — Function
build_ode_system(model; write_to_file=false, filename=nothing)
build_ode_system(model_set; model_id, kwargs...)

Lower a parsed DynMS model to a native HetaODESystem.

When write_to_file=true, readable Julia source for the resulting system is also written to filename.

HetaImporter.write_generated_code — Function
write_generated_code(system, filename)

Write the fixed native Julia functions stored in system.generated_code to a readable source file. No code is regenerated.

HetaImporter.observed — Function

Return the assignment-rule expressions available as observed variables.

HetaImporter.events — Function

Return the time, continuous, discrete, and stop event definitions.