Library Reference

Base.Dict — Method
Dict(x::AbstractTerm)

to register your type with JSON3, you need to overload JSON3.write to use this Dict approach. we only overload the Dict function for our type Formula, so this is not piracy.

source
SyntacticModels.SyntacticModelsBase.AbstractTerm — Type
AbstractTerm

The super type for all SyntacticModels types. This abstract type exists so that we can write generic methods that work on any term in any of the domain specific syntaxes. For example, serializing to a Dictionary uses some reflection snippet that works for arbitrary types, but we only want to apply it to things that should be serialized like a Term.

source
JSON3.write — Method
JSON3.write

Now JSON3.write(f) puts the type information in our reserved field.

source
StructTypes.subtypekey — Method
StructTypes.subtypekey

This is how you tell StructTypes where to look for the name of a type when reading the type back in from JSON.

source
SyntacticModels.SyntacticModelsBase._dict — Method
_dict(x::T) where T <: AbstractTerm

We are going to convert our structs to Dict before we call JSON3.write and add the type information in a generic construction. This uses some reflection to ask the julia type for its fieldnames and then use those as the keys in the Dict. We use splatting, so don't make a struct with more than 32 fields if you want to go fast. We use this _dict function to avoid an "I'm the captain now" level of type piracy.

source

UWDs

SyntacticModels.ASKEMUWDs.UWDTerm — Type
UWDTerm

Term specifying UWD.

Subtypes

  1. UWDModel: A header and UWD Expr
  2. UWDExpr: A Context of variables and a list of statements defining a UWD
  3. Statement: R(x,y,z) a relation that acts on its arguments (which are Vars)

Example

To specify the following relation macro:

@relation (x:X, z:Z) where y:Y begin
  R(x,y)
  S(y,z)
  T(z,y,u)
end

Use the following SyntacticModels UWDTerm:

v1 = Typed(:x, :X)
v2 = Typed(:y, :Y)
v3 = Typed(:z, :Z)
v4 = Untyped(:u)
c = [v1, v3]
s = [Statement(:R, [v1,v2]),
  Statement(:S, [v2,v3]),
  Statement(:T, [v3,v2, v4])]
u = UWDExpr(c, s)
source
SyntacticModels.ASKEMUWDs.Var — Type
Var

Variables of a UWD. Types are the domain types, ScalarField, VectorField, Dual1Form, Primal2Form NOT Float64,Complex128

Subtypes include:

  1. Untyped(var::Symbol)
  2. Typed(var::Symbol, type::Symbol)

which are used for representing typed or untyped variables.

source
Base.show — Method
show(io::IO, s::UWDTerm)

generates a human readable string of the UWDTerm (or any sub-term).

source

Decapodes

Composites

SyntacticModels.Composites.CompositeModel — Type
CompositeModel
@data CompositeModel <: AbstractTerm begin
  OpenModel(model::ASKEMDecapodes.ASKEMDecaExpr, interface::Vector{Symbol})
  OpenDecapode(model::ASKEMDecapodes.ASKEMDecapode, interface::Vector{Symbol})
  CompositeModelExpr(header::Header, composition_pattern::UWDExpr, components::Vector{CompositeModel})
end
source
Catlab.WiringDiagrams.WiringDiagramAlgebras.oapply — Method
Catlab.oapply(m::CompositeModel)

CompositeModels can be flattened into a single level of model with the oapply function.

Warning

Because the oapply algorithm operates on the compute graph representation of the equations, it does not produce syntactic equations. Calls to oapply produce instances of OpenDecapode and not DecaExpr. Software that expects to consume decapodes should plan to interact with both forms.

source
SyntacticModels.Composites.interface — Method
interface(m::CompositeModel)

Extract the interface of a composite model. If the model is open, then it is the feet of the cospan. If it is a Composite, then it is the context of the uwd.

source