Comments (4)
Thanks for the explanation! I'll try my best.
from brim.
Hello, I am a student trying to contribute for the first time. I'm asking a question because I don't quite understand the issue. Looking at the issue content, it looks like I need to simply create a static method that returns self.symbol. Is my understanding correct?
from brim.
Each component in BRiM has an attribute symbols
, which is a dictionary mapping descriptive names to the symbol objects, e.g. {"radius": self.Symbol(f"{self.name}_radius")}
. This new method should gather all the defined symbols in a model and return it as a set. The bigger picture is that a user can quickly check if (s)he forgot to define any symbols. I would expect the function to have the following format, but if you have better ideas feel free to make suggestions:
from sympy import Basic
from sympy.physics.mechanics import find_dynamicsymbols, dynamicsymbols
def get_all_symbols(self) -> set[Basic]:
"""Get all declared symbols of a model."""
syms = set()
# Get local symbols.
for sym in model.symbols.values():
# Extract symbols if an expression is set as symbol.
if isinstance(sym, Basic):
syms.update(sym.free_symbols)
syms.update(find_dynamicsymbols(sym))
if dynamicsymbols._t in syms: # Remove t.
syms.remove(dynamicsymbols._t)
# Traverse children.
if hasattr(self, "submodels"):
for submodel in self.submodels:
syms.update(get_all_symbols(submodel))
if hasattr(self, "connections"):
for conn in self.connections:
syms.update(get_all_symbols(conn))
if hasattr(self, "load_groups"):
for load_group in self.load_groups:
syms.update(get_all_symbols(load_group))
return syms
P.S. I just required this function, so I wrote up a quick implementation. For testing, I would advise a few tests. One to check the traversal in general. And one using pytest.mark.parametrize
to check the different overrides of symbols, e.g. wheel.symbols["r"] = expr
, where expr
can be Symbol("r")
, 0
, 1
, dynamicsymbols("r")
, Symbol("r_def") - dynamicsymbols("r_var")
.
from brim.
Due to inactivity, this issue will be solved in #111
from brim.
Related Issues (20)
- Redundant _parent attribute in ConnectionBase
- Change frozenset usage to frozen dictionaries? HOT 2
- BicycleParameters adjusts the rear frame CoM based on the rider
- Simplify contact point computation
- Redesign plotting structure
- Refactor test suite
- Make q, u default Matrix properties
- Improve module names
- RiderLean model
- Change base orientation of frames in the rider HOT 2
- Use benchmark results
- Fix broken links
- Rear and Front frame should not use NewtonianBodyMixin HOT 1
- Regression of the number of operations in the EOMs after CSE HOT 2
- Add tutorials HOT 1
- Diagrams can't be read in dark mode HOT 1
- Feedback BRiM tutorials session
- Feature request: get unspecified components
- Holonomic constraints in HolonomicHandGrips and HolonomicPedals are incompatible with noncontributing forces
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from brim.