AlgebraicJulia / AlgebraicJulia/Decapodes.jl

Idea: Exploit hierarchical composition in simulation generation

Offen
#266 2 Kommentare 0 Reaktionen 1 zugewiesene Person Beansprucht von @lukem12345 Auf GitHub ansehen
enhancement
Vorherrschende Sprache
Julia
Sterne
91
Forks
18
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

Currently, we generate simulation code only on single Decapode objects, after oapply is performed.

However, we could take advantage of repeated sub components which only differ in the pointers to their inputs and outputs. For each node in a composition diagram for which the same Decapode is plugged in, we could compile it to a simulation helper function, which could be re-used inside the main ODEProblem function generated.

This will surely result in simulation functions with fewer total lines of code. However, it is not apparent whether this would result in more efficient generated code that the Julia compiler can optimize, or whether this could improve pre-compile times.

So, we should manually create an example of this generated code and compare. A reasonable example would use the unconnected RelationDiagram of 2 or more distinct nodes, plugging in e.g. the Brusselator Decapode for each component. (I.e. The strategy used for [non-interacting multi-species Navier-Stokes](https://github.com/AlgebraicJulia/Decapodes.jl/issues/70#issuecomment-1421598346).)

An occurrence of this “in the wild” is the [hierarchical composition in the Non-Hydrostatic Buoyancy example](https://algebraicjulia.github.io/Decapodes.jl/dev/nhs/nhs_lite/#Compatibility-Guarantees-via-Operadic-Composition), in which tracer computations for salinity and temperature are repeated:

```julia
isotropic_nonhydrostatic_buoyancy = apex(oapply(nonhydrostatic_composition, [
Open(momentum, [:V, :v, :b, :StressDivergence]),
Open(isotropic_tracer, [:continuity_V, :v, :c, :turbulence_StressDivergence, :turbulence_nu]),
Open(isotropic_tracer, [:continuity_V, :v, :c, :turbulence_StressDivergence, :turbulence_nu]),
Open(equation_of_state, [:b, :T, :S])]));
to_graphviz(isotropic_nonhydrostatic_buoyancy)
```

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.