Unit conversion in Simbiology model
16 ビュー (過去 30 日間)
古いコメントを表示
Rajeev Kumar
2024 年 10 月 8 日
コメント済み: Rajeev Kumar
2024 年 11 月 3 日 22:55
I am trying to understand how unit conversion has been implemented in model developed in Simbiology model being executed in matlab envioronemt. If unit conversion is enabled - will it convert only time unit or other parameters as well. This becomes critical in my work. My questions are listed below-
1. If unit conversion feature enables in simbiology project - What units are being converted? Can you provide the general script to access this information?
2. What are the global units of such model (simbiology developed models?)
3. How to access the parameter names and values which are being used to solve equations using ode solver?
Please take this query as urgent.
Thanks in advance for your help.
0 件のコメント
採用された回答
Arthur Goldsipe
2024 年 10 月 8 日
Hi, I'm a developer on the SimBiology team. I'm not sure I fully understand your question, but I'll try to answer based on my current understand. However, since you mention that this query is urgent, I also want to mention that MATLAB Answers is may not the best venue for urgent questions. You may prefer to directly contact MathWorks, so that an experienced engineer can work cirectly with you to answer your questions. You can find options for that here.
You can find more information about unit conversion on this reference page. Unit conversion applies to all quantities in your model, not just time. When you enable unit conversion in SimBiology, you must add unit information to all quantities in your model. Then, when you write expressions, SimBiology will ensure that your expression is dimensionally consistent and perform all the appropriate unit conversions to perform. For example, let's say you have an assignment rule "x = y + z", x has units of mole, y has units of millimole, and z has units of micromole. SimBiology can see that all three quantities have the same dimensions of amount, and so the rule expression is dimensionally consistent. Then, it will internally convert everything to consistent units before performing the addition, but all values will be reported back to you in the units you specify.
I'm not sure what you mean by global units. You can specify whatever units you want on the model. Perhaps you are asking what units SimBiology uses internally when simulating the model. If so, those are implementation details that we don't generally provide to users, becaue for the most part they shouldn't affect the user's results. This allows us to change the implementation as needed for future enhancements. That said, we do document a couple a few aspects of the internal units used during simulation. If you look at this page, you will see the options AmountUnits, MassUnits, and TimeUnits. These options can be used to control the internal amount, mass, and time units used by SimBiology. If you need more details, I can provide them. But I would need to understand your question better to provide an appropriate answer. What information do you need and why do you need it?
As for your final question, the person who creates the SimBiology model determines the names of parameters. You can then reference parameters by names wherever you need to reference their values.
I also recommend you take a look at the SimBiology documentation. In particular, you may find wnat to look at the Getting Started section and the Examples (many of which use unit conversion).
3 件のコメント
Arthur Goldsipe
2024 年 10 月 9 日
Let me rephrase your question to make sure I understand it. You'd like to be able inspect the internal values that species or parameters have over the course of a simulation, so that you can debug the model.
For debugging, I generally recommend downloading and using the SimBiology Model Debugger. That tool allows you to step through simulations interactively and inspect how values change. However, it only reports the values to you in the units you specify. The tool does not report the internal values used.
If you really want to see the internal values during simulation, I can only think of one way to do that, and it has at least one major (and one minor) caveat. My idea is related to the Tip listed under UnitConversion on this reference page. Specifically, you must write your own MATLAB function and use it in your model. Anything you specify as an input will be passed to the function in internal engine units. Let's continue the "x = y + z" example. You could move that addition into your own function named "myAdd". Then, change the repeated assignment rule in your model to "x = myAdd(y, z)". Then, function myAdd will receive inputs y and z in the same internal "engine" units. You can then debug myAdd using whatever approach you like to "see" those values. However, here's the caveat: The function may be called with intermediate results that are ultimately discarded by the solver; there is no way to know within this function whether the values you get are part of the solution or an intermediate result. A second minor caveat is that you will see a warning that SimBiology cannot do dimensional analysis the myAdd function (or whatever you name it). You can safely ignore this messafe, one you confirm that your function behaves as desired.
In case the above caveats are acceptable, I've attached a couple of files that illlustrate the approach. In the model, y is converted to z, and x = y + z. So x should remain constant throughout the simulation. My function prints out time, x, y, and z in internal units every time the function is called. The internal units could be different in different releases, but in R2024b this shows that x, y, and z are internally stored with units of micromole. And if you compare this output to the final results, you'lll see that the function is called many more times. But perhaps that is good enough for your needs.
inspectUnits
その他の回答 (0 件)
コミュニティ
その他の回答 SimBiology コミュニティ
参考
カテゴリ
Help Center および File Exchange で Extend Modeling Environment についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!