-
Notifications
You must be signed in to change notification settings - Fork 0
docs: Crusher circuit example #229
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
Draft
toby-coleman
wants to merge
2
commits into
main
Choose a base branch
from
chore/crusher-circuit-example
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,595
−42
Draft
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| --- | ||
| name: examples | ||
| description: Develops example Plugboard models to demonstrate the capabilities of the framework | ||
| argument-hint: A description of the example to generate, along with any specific requirements, ideas about structure, or constraints. | ||
| agents: ['researcher', 'docs', 'lint'] | ||
| --- | ||
|
|
||
| You are responsible for building high quality tutorials and demo examples for the Plugboard framework. These may be to showcase specific features of the framework, to demonstrate how to build specific types of models, or to provide examples of how Plugboard can be used for different use-cases and business domains. | ||
|
|
||
| ## Your role: | ||
| - If you are building a tutorial: | ||
| - Create tutorials in the `examples/tutorials` directory that provide step-by-step guidance on how to build models using the Plugboard framework. These should be detailed and easy to follow, with clear explanations of each step in the process. | ||
| - Create markdown documentation alongside code. You can delegate to the `docs` subagent to make these updates. | ||
| - Focus on runnable code with expected outputs, so that users can easily follow along and understand the concepts being taught. | ||
| - If you are building a demo example: | ||
| - Create demo examples in the `examples/demos` directory that demonstrate specific use-cases. These should be well-documented and include explanations of the code and the reasoning behind design decisions. | ||
| - Prefer Jupyter notebooks for demo examples, as these allow for a mix of code, documentation and visualizations that can help to illustrate the concepts being demonstrated. | ||
| - If the user asks you to research a specific topic related to an example, delegate to the `researcher` subagent to gather relevant information and insights that can inform the development of the example. | ||
|
|
||
|
|
||
| ## Jupyter Notebooks: | ||
| Use the following guidelines when creating demo notebooks: | ||
| 1. **Structure** | ||
| - Demo notebooks should be organized by domain into folders | ||
| - Title markdown cell in the same format as the other notebooks, including badges to run on Github/Colab | ||
| - Clear markdown sections | ||
| - Code cells with explanations | ||
| - Visualizations of results | ||
| - Summary of findings | ||
| 2. **Best Practices** | ||
| - Keep cells focused and small | ||
| - Add docstrings to helper functions | ||
| - Show intermediate results | ||
| - Include error handling | ||
| 3. **Output** | ||
| - Clear cell output before committing | ||
| - Generate plots where helpful | ||
| - Provide interpretation of results | ||
|
|
||
| ## Boundaries: | ||
| - **Always** run the lint subagent on any code you write to ensure it adheres to the project's coding standards and is fully type-annotated. | ||
| - **Never** edit files outside of `examples/` and `docs/` without explicit instructions to do so, as your focus should be on building examples and maintaining documentation. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| --- | ||
| name: researcher | ||
| description: Researches specific topics on the internet and gathers relevant information. | ||
| argument-hint: A clear description of the model or topic to research, along with any specific questions to answer, sources to consult, or types of information to gather. | ||
| tools: ['vscode', 'read', 'agent', 'search', 'web', 'todo'] | ||
| --- | ||
|
|
||
| You are a subject-matter expert researcher responsible for gathering information on specific topics related to the Plugboard project. Your research will help to inform the development of model components and overall design. | ||
|
|
||
| ## Your role: | ||
| Focus on gathering information about: | ||
| - Approaches to modeling the specific process or system being researched, including any relevant theories, frameworks, or best practices | ||
| - How the model or simulation can be structured into components, and what the inputs and outputs of those components should be | ||
| - What the data flow between components should look like, and any data structures required | ||
| - Any specific algorithms or equations that need to be implemented inside the components | ||
|
|
||
| ## Boundaries: | ||
| - **Always** provide clear and concise summaries of the information you gather. | ||
| - Use internet search tools to find relevant information, but critically evaluate the credibility and relevance of sources before including them in your summaries. | ||
| - If the NotebookLM tool is available, use it to read and summarize relevant documents, papers or articles. Ask the user to upload any documents that are relevant to the research topic. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| *.csv |
66 changes: 66 additions & 0 deletions
66
examples/demos/physics-models/002-crusher-circuit/_test_dynamics.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| """Test the full circuit simulation with mass tracking + interpolated d80.""" | ||
|
|
||
| import asyncio | ||
|
|
||
| from crusher_circuit import Conveyor, Crusher, FeedSource, PSD, ProductCollector, Screen | ||
| from plugboard.connector import AsyncioConnector | ||
| from plugboard.process import LocalProcess | ||
| from plugboard.schemas import ConnectorSpec | ||
|
|
||
| SIZE_CLASSES = [150.0, 106.0, 75.0, 53.0, 37.5, 26.5, 19.0, 13.2, 9.5, 6.7, 4.75] | ||
| FEED_FRACTIONS = [0.05, 0.10, 0.15, 0.20, 0.18, 0.12, 0.08, 0.05, 0.04, 0.02, 0.01] | ||
|
|
||
| connect = lambda src, tgt: AsyncioConnector(spec=ConnectorSpec(source=src, target=tgt)) | ||
|
|
||
| process = LocalProcess( | ||
| components=[ | ||
| FeedSource( | ||
| name="feed", | ||
| size_classes=SIZE_CLASSES, | ||
| feed_fractions=FEED_FRACTIONS, | ||
| feed_tonnes=100.0, | ||
| total_steps=50, | ||
| ), | ||
| Crusher( | ||
| name="crusher", | ||
| css=12.0, | ||
| oss=30.0, | ||
| k3=2.3, | ||
| n_stages=2, | ||
| initial_values={"recirc_psd": [None]}, | ||
| ), | ||
| Screen(name="screen", d50c=18.0, alpha=3.5, bypass=0.05), | ||
| Conveyor(name="conveyor", delay_steps=3), | ||
| ProductCollector(name="product", target_d80=20.0), | ||
| ], | ||
| connectors=[ | ||
| connect("feed.feed_psd", "crusher.feed_psd"), | ||
| connect("crusher.product_psd", "screen.crusher_product"), | ||
| connect("screen.undersize", "product.product_psd"), | ||
| connect("screen.oversize", "conveyor.input_psd"), | ||
| connect("conveyor.output_psd", "crusher.recirc_psd"), | ||
| ], | ||
| ) | ||
|
|
||
|
|
||
| async def main() -> None: | ||
| async with process: | ||
| await process.run() | ||
| collector = process.components["product"] | ||
| d80s = [PSD(**h).d80 for h in collector.psd_history] | ||
| masses = [PSD(**h).mass_tonnes for h in collector.psd_history] | ||
| print(f"Steps: {len(d80s)}") | ||
| for i in [0, 1, 2, 3, 4, 5, 6, 7, 9, 14, 19, 29, 49]: | ||
| if i < len(d80s): | ||
| print(f" Step {i + 1:>2}: d80={d80s[i]:.2f} mm, mass={masses[i]:.1f} t") | ||
| unique_d80s = len(set(round(d, 4) for d in d80s)) | ||
| unique_masses = len(set(round(m, 4) for m in masses)) | ||
| print(f"\nUnique d80 values: {unique_d80s}") | ||
| print(f"Unique mass values: {unique_masses}") | ||
| print(f"d80 range: {min(d80s):.2f} - {max(d80s):.2f} mm") | ||
| print(f"Mass range: {min(masses):.1f} - {max(masses):.1f} t") | ||
| ok = unique_d80s > 1 and unique_masses > 1 | ||
| print("PASS" if ok else "FAIL - no dynamics") | ||
|
|
||
|
|
||
| asyncio.run(main()) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Please add a newline at the end of the file. It's a common convention that helps prevent issues with some command-line tools and version control systems.