Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/algjulia-interop/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,14 @@ IJulia = "7073ff75-c697-5162-941a-fcdaad2a7d2a"
JSON3 = "0f8b85d8-7281-11e9-16c2-39a750bddbf1"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
MLStyle = "d8e11817-5142-5d16-987a-aa16d5891078"
OrderedCollections = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
PackageCompiler = "9b87118b-4619-50d2-8e1e-99f35a4d4d9d"
Preferences = "21216c6a-2e73-6563-6e65-726566657250"
REPL = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"

[weakdeps]
PackageCompiler = "9b87118b-4619-50d2-8e1e-99f35a4d4d9d"

[extensions]
SysImageExt = "PackageCompiler"

Expand All @@ -44,6 +43,7 @@ IJulia = "1.26.0"
JSON3 = "1"
LinearAlgebra = "1"
MLStyle = "0.4"
OrderedCollections = "1.8.1"
OrdinaryDiffEq = "6.101.0"
PackageCompiler = "2.2.1"
Preferences = "1.5.0"
Expand Down
5 changes: 5 additions & 0 deletions packages/algjulia-interop/docs/literate/json.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
using CatColabInterop

using JSON3

json = JSON3.read(read("test/test_jsons/_payload.json"))
77 changes: 12 additions & 65 deletions packages/algjulia-interop/src/CatColabInterop.jl
Original file line number Diff line number Diff line change
@@ -1,86 +1,33 @@
module CatColabInterop

import Base: run
using JSON3
using MLStyle
using Reexport

# this code tracks integrations and allows for basic theory/model-building code to dispatch from it.
# the intent is that this is an interface for AlgebraicJulia code to interoperate with CatColab
abstract type AlgebraicJuliaIntegration end

# cells in the JSON are tagged. these are just objects for dispatching `to_model`
@data ModelElementTag begin
ObTag()
HomTag()
end
export ObTag, HomTag

#=
@active patterns are MLStyle-implementations of F# active patterns that forces us to work in the Maybe/Option pattern.
Practically, yet while a matter of opinion, they make @match statements cleaner; a statement amounts to a helpful pattern
name and the variables we intend to capture.
=#
@active IsObject(x) begin; x[:content][:tag] == "object" ? Some(x[:content]) : nothing end
@active IsMorphism(x) begin; x[:content][:tag] == "morphism" ? Some(x[:content]) : nothing end
export IsObject, IsMorphism

# Obs, Homs
@data ModelElementValue begin
ObValue()
HomValue(dom,cod)
end
export ObValue, HomValue

"""
Struct capturing the name of the object and its relevant information.
ModelElementValue may be objects or homs, each of which has different data.
"""
struct ModelElement
name::Union{Symbol, Nothing}
val::Union{<:ModelElementValue, Nothing}
function ModelElement(;name::Symbol=nothing,val::Any=nothing)
new(name, val)
end
end
export ModelElement

Base.nameof(t::ModelElement) = t.name

""" Struct wrapping a dictionary """
struct Model{T<:AlgebraicJuliaIntegration}
data::Dict{String, ModelElement}
end
export Model

function Model(::T) where T<:AlgebraicJuliaIntegration
Model{T}(Dict{String, ModelElement}())
end

Base.values(model::Model) = values(model.data)

"""
Functions to build a dictionary associating ids in the theory to elements in the model
"""
function to_model end
export to_model


# TODO supposes bijection between theories, models, diagrams, etc.
abstract type AbstractDiagram{T<:AlgebraicJuliaIntegration} end

abstract type AbstractAnalysis{T<:AlgebraicJuliaIntegration} end
#= These files are responsible for parsing the model and diagram in the CCL payload =#
include("qualified_name.jl")
include("model.jl")
include("diagram.jl")
include("payload.jl") # payload and analysis are here

struct ImplError <: Exception
name::String
end
export ImplError

Base.showerror(io::IO, e::ImplError) = print(io, "$(e.name) not implemented")

include("result.jl")
include("kernel_management.jl")
include("kernel_support.jl")
# Kernel utilities
include("kernel/KernelUtility.jl")

#= The Decapodes service contains an analysis =#
include("decapodes-service/DecapodesService.jl")

@reexport using .KernelUtility
@reexport using .DecapodesService

end
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module DecapodesService

import Base: run

# algebraicjulia dependencies
using ACSets
using DiagrammaticEquations
Expand All @@ -17,26 +19,37 @@ using Distributions # for initial conditions
# meshing
using CoordRefSystems
using GeometryBasics: Point2, Point3
Point3D = Point3{Float64};
Point3D = Point3{Float64}

# simulation
using OrdinaryDiffEq

using ..CatColabInterop
using ..CatColabInterop: AlgebraicJuliaIntegration, AbstractDiagram, AbstractAnalysis
import ..CatColabInterop: Model, to_model
import ..CatColabInterop: Model, ObGenerator, MorGenerator, DiagramObGenerator, DiagramMorGenerator

# necessary to export
export infer_types!, evalsim, default_dec_generate, default_dec_matrix_generate,
DiagonalHodge, ComponentArray
export infer_types!, evalsim, default_dec_generate, default_dec_matrix_generate, DiagonalHodge, ComponentArray

struct ThDecapode <: AlgebraicJuliaIntegration end
export ThDecapode

# funcitons for geometry and initial conditions
# functions for geometry and initial conditions
include("geometry.jl")
include("model.jl") ## model-building
include("diagram.jl") ## diagram-building
include("analysis/Analysis.jl")

# responsible for constructing a valid model
include("model.jl")

# helper functions for Navier-Stokes
include("ns_helper.jl")

# constructing initial conditions
include("initial_conditions.jl")

# parses a payload to a valid analysis
include("parse.jl")

# executes the analysis
include("execute.jl")

end

This file was deleted.

161 changes: 0 additions & 161 deletions packages/algjulia-interop/src/decapodes-service/analysis/simulation.jl

This file was deleted.

Loading