Modelica - 如何实现记录的构造函数
实现记录构造函数的最佳方法是什么?似乎函数应该能够在树上更高的某个模型中的记录实例化中返回记录对象,但我无法使其工作。目前,我只是在记录顶部使用一堆参数来填充记录中存储的变量,但似乎这只适用于简单的情况。
有人能透露一点吗?也许我不应该使用记录而应该使用模型。还有人知道 PDE 功能是如何实现的吗?书上只说它即将到来,但我还看到了一些其他的事情。
What is the best way to implement a constructor for a record? It seems like a function should be able to return a record object in the instantiation of the record in some later model higher up the tree, but I can't get that to work. For now I just use a bunch of parameters
at the top of the record that populate the variables stored in the record, but it seems like that will only work in simple cases.
Can anyone shed a little light? Perhaps I shouldn't be using a record but a model. Also does anyone know how the PDE functionality is coming? The book only says that it is coming, but I have seen some other things around.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我似乎没有能力添加标签(这是有道理的,因为我的“声誉”低于你的)对此感到抱歉。我以为我实际上在某一时刻添加了一个,但也许我错了。
我认为您需要清楚构造函数的含义,因为它在 Modelica 中具有非常具体的含义。如果我正确理解你的问题,听起来你想要做的是创建一个记录的实例,该实例具有在构造函数参数中指定的一些字段,并根据这些参数计算记录中的一堆其他字段。这是正确的吗?
如果是这样,就有一个机制可以做到这一点。您提到“这本书”,但不清楚您指的是哪一本书。如果是我的,它肯定没有提到这些所谓的“记录构造函数”,因为它太旧了。我也不知道Peter Fritzson的书中是否提到了它们。但是,它们确实存在,并记录在 Modelica 3.2 规范 的第 12.6 节中。
至于偏微分方程,已经开展了此类工作,但设计组在该主题上还没有真正做任何事情。我想补充一点,如果您想在规则网格上求解椭圆或抛物线偏微分方程,即使使用当前的语言,这也不是太难。唯一真正的缺点是大多数工具可能不能非常有效地处理稀疏性。不规则网格也是可能的,但随后您会遇到复杂的基函数。最后,在我看来,双曲偏微分方程(在任何环境下)都非常棘手,因为时间和空间之间隐含的物理约束很难表达(即 CFL 条件)。
我希望到目前为止能回答您的问题。
I don't seem to have the clout to add tags (which makes sense, since my "reputation" is lower than yours) so sorry about that. I thought I had actually added one at one point, but perhaps I am mistaken.
I think you need to be clear what you mean by constructor since it has a very specific meaning in Modelica. If I understand your question correctly, it sounds like what you want to do is create an instance of a record that has some fields that are specified in the constructor arguments and from those arguments a bunch of other fields in the record are computed. Is that correct?
If so, there is a mechanism to do this. You mention "the book" but it isn't clear which one you mean. If it is mine, it definitely has no mention of these so called "record constructors" because it is too old. I do not know if Peter Fritzson's book mentions them either. However, they do exist and are documented in Section 12.6 of the Modelica 3.2 specification.
As for PDEs, there has been work into this kind of thing but nothing has really been done within the design group on this topic. I would add that if you want to solve either elliptical or parabolic PDEs on regular grids, this isn't too hard even with the current language. The only real drawback is that most tools probably don't handle sparsity very efficiently. Irregular grids would also be possible, but then you get into complicated basis functions. Finally, hyperbolic PDEs are, in my opinion, quite tricky (in any environment) due to the implicit physical constraints between time and space which are difficult to express (i.e. the CFL condition).
I hope that answers your questions so far.
我只能评论你关于彼得·弗里茨森的书的问题。他确认他正在进行更新,并希望“在 2011 年期间”做好准备。
原始帖子在这里:
http://openmodelica.org/index.php/forum/topic ?id=50
感谢您启动 modelica 标签,在不久的将来我可能也会对我有用...:-)
问候,
罗尔
I can only comment on your question regarding the book of Peter Fritzson. He confirmed that he's working on an update and he hopes to get it ready 'in the course of 2011'.
Original post here:
http://openmodelica.org/index.php/forum/topic?id=50
And thanks for initiating the modelica tag, I might be useful in the near future for me too... :-)
regards,
Roel