-
Notifications
You must be signed in to change notification settings - Fork 2
Add ModelingToolkit.jl extension #16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds a ModelingToolkit.jl extension to SolarPosition.jl, enabling integration of solar position calculations into symbolic modeling workflows for applications like solar energy modeling, building thermal analysis, and solar tracking systems.
Key changes:
- Created
SolarPositionModelingToolkitExtextension that provides aSolarPositionBlockcomponent for computing solar azimuth, elevation, and zenith angles as time-varying symbolic variables - Added comprehensive tests demonstrating component creation, composition with other systems, and ODE solving
- Added documentation with examples showing integration with solar panel and building thermal models
Reviewed Changes
Copilot reviewed 12 out of 13 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
ext/SolarPositionModelingToolkitExt.jl |
Implements the ModelingToolkit extension with SolarPositionBlock component and symbolic function registration |
src/SolarPosition.jl |
Exports new types and adds comprehensive docstring for SolarPositionBlock |
src/Positioning/Positioning.jl |
Introduces AbstractApparentSolPos type hierarchy for better type organization |
test/test-mtk.jl |
Adds tests for block creation, composition, and ODE solving with plotting validation |
test/runtests.jl |
Comments out previous imports (follows existing pattern for auto-discovery) |
test/Project.toml |
Adds test dependencies for ModelingToolkit, OrdinaryDiffEq, and CairoMakie |
docs/src/examples/modelingtoolkit.md |
Comprehensive guide with examples of solar panel and building thermal models |
docs/src/index.md |
Documents the new ModelingToolkit extension in the main index |
docs/make.jl |
Adds modelingtoolkit.md to documentation build |
docs/Project.toml |
Adds ModelingToolkit and OrdinaryDiffEq for documentation builds |
examples/mtk-integration.jl |
Commented example code demonstrating various use cases |
examples/Project.toml |
Declares dependencies for examples |
Project.toml |
Adds ModelingToolkit and Symbolics as weak dependencies with compat entries |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #16 +/- ##
==========================================
+ Coverage 92.36% 92.74% +0.37%
==========================================
Files 15 15
Lines 511 510 -1
==========================================
+ Hits 472 473 +1
+ Misses 39 37 -2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
@copilot run Julia formatter to pass linting CI |
|
@langestefan I've opened a new pull request, #17, to work on those changes. Once the pull request is ready, I'll request review from you. |
Co-authored-by: langestefan <37669773+langestefan@users.noreply.github.com>
Run Julia formatter to fix linting CI
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 14 out of 15 changed files in this pull request and generated 9 comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 21 out of 22 changed files in this pull request and generated 3 comments.
| ```julia | ||
| using SolarPosition, ModelingToolkit | ||
| using ModelingToolkit: t_nounits as t | ||
| using Dates | ||
| @named sun = SolarPositionBlock() | ||
| obs = Observer(51.5, -0.18, 15.0) | ||
| t0 = DateTime(2024, 6, 21, 12, 0, 0) | ||
| sys = mtkcompile(sun) | ||
| pmap = [ | ||
| sys.observer => obs, | ||
| sys.t0 => t0, | ||
| sys.algorithm => PSA(), | ||
| sys.refraction => NoRefraction(), | ||
| ] | ||
| prob = ODEProblem(sys, pmap, (0.0, 86400.0)) | ||
| sol = solve(prob; saveat = 3600.0) | ||
| ``` |
Copilot
AI
Nov 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The example code is incomplete and missing required imports. The code uses @named (line 86) and mtkcompile (line 90) from ModelingToolkit, and ODEProblem and solve (lines 98-99) from OrdinaryDiffEq, but these are not imported. Add the following imports to make the example self-contained:
using SolarPosition, ModelingToolkit
using ModelingToolkit: t_nounits as t, @named, mtkcompile
using Dates
using OrdinaryDiffEq: ODEProblem, solve| using ModelingToolkit: t_nounits as t, D_nounits as D | ||
| using Dates: DateTime | ||
| using OrdinaryDiffEq | ||
| using CairoMakie |
Copilot
AI
Nov 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing import for TimeZones functions. The test uses astimezone (line 183) and tz"UTC" (line 183) from TimeZones package but doesn't import TimeZones. Add using TimeZones: astimezone, @tz_str at the top of this file.
| using CairoMakie | |
| using CairoMakie | |
| using TimeZones: astimezone, @tz_str |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This will add an extension for ModelingToolkit.jl to enable creation of solar position modeling blocks that can be plugged into any symbolic model.