f*******r 发帖数: 901 | 1 我是学mechanical engineering的。现在准备用C++算一个thermal system的优化问题
。所以想来这里向各位高手请教。
首先,为什么用C++?
1. 以前用Fortran 编程作数值计算,但是每次thermal system 一点小改动,我的
Fortran 程序就要改好多,所以就想用C++。
2。Thermal system的每一个部件,象冷水机组,冷却塔,水泵,换热器等等,正好可
以用class描述,然后整个系统用由这些classes组成的一个新类来描述。这样很符合面
向对象的思路。
我的问题是这个程序主要结构应该怎么样?
在说这个问题之前,再来说说thermal system的优化问题做什么。我们知道每一个部件
的能耗和运行参数(温度,流量等)的关系,想算出对于一个系统在哪一组运行参数下
的能耗最小。现在的程序先只考虑对一个特定的系统(每一个部件都已经确定了)做优
化。将来还要考虑对系统里好多部件不确定要有程序来选择然后计算一组能耗最小的运
行参数。
具体到数学上,就是求一个多元函数E(能耗)的的最小值。最开始可能是无条件的最小
值,以后会算许多条件下一个函数的最小值。算法有两类,一类是解析解,一类是搜索
方法。
现在先考虑解析方法。准备用Lagerange Multipliers方法。就是从一个函数E和一些条
件方程(非线性的方程)推导出一个方程组(非线性方程组),解这个方程组就得到了
最优化的运行参数。这个方程组里的很多项是这个函数E和这些条件方程的导数。
以前用Fortran这种面向过程的语言,就是先直接推导出这个优化方程组,然后用
Fortran编程解这个优化方程组(用迭代的方法)。但是问题就来了,每次对系统的小
改动,都要重新推导这个优化方程组,然后改程序解这个优化方程组。
现在我想尝试用C++来完成这个推导优化方程组得工作,然后再解这个方程组来得到优
化的运行参数。这样以后系统的改动,我只需要改动程序里那些改动了的部件的class
就可以了。
我的设想是:
1. 系统里每一个部件由一class来描述。这个class有函数来表达这个部件的能耗和条
件方程。
2.整个系统由一个class描述,这个system class由描述那些部件的classes组成。这个
system class 也有函数表达整个系统的能耗和条件方程。但是在程序初始,这些表达
整个系统的能耗和条件方程的函数是未知的,需要通过system class里面描述那些部件
的classes的函数来生成。
我的问题是:
1.我的设想是否可行,合理? |
f*******r 发帖数: 901 | |
N***m 发帖数: 4460 | 3 first of all, fortan 90 can do oop pretty well.
So why do you need c++?
second, what do you mean derivative in c++/compiler?
you want c++ to do it analytically?
【在 f*******r 的大作中提到】 : 我是学mechanical engineering的。现在准备用C++算一个thermal system的优化问题 : 。所以想来这里向各位高手请教。 : 首先,为什么用C++? : 1. 以前用Fortran 编程作数值计算,但是每次thermal system 一点小改动,我的 : Fortran 程序就要改好多,所以就想用C++。 : 2。Thermal system的每一个部件,象冷水机组,冷却塔,水泵,换热器等等,正好可 : 以用class描述,然后整个系统用由这些classes组成的一个新类来描述。这样很符合面 : 向对象的思路。 : 我的问题是这个程序主要结构应该怎么样? : 在说这个问题之前,再来说说thermal system的优化问题做什么。我们知道每一个部件
|
b******g 发帖数: 81 | 4 To answer your two questions:
1. 解析方法 is the reason of your maintenance issue. Your formula need to
change when devices change. Numerical analysis seem more promising.
2. My computer science knowledge only tells me Newton-Raphson method -
which is numerical analysis, not symbolic analysis. You might need some
special library to do the symbolic analysis. |
f*******r 发帖数: 901 | 5
谢谢兄台的回复。
用C++是我更熟悉C和C++. Fortran 90 关于OPP方面的编程我从来没有接触过。
我是想在我得C++程序里实现symbolic analysis (接用另外一个兄台的话).
【在 N***m 的大作中提到】 : first of all, fortan 90 can do oop pretty well. : So why do you need c++? : second, what do you mean derivative in c++/compiler? : you want c++ to do it analytically?
|
f*******r 发帖数: 901 | 6
多些兄台的指点。我想你说的symbolic analysis,正是我想要的。从来没有接触过这
方面的编程,不知道哪里能找到这方面的信息。
【在 b******g 的大作中提到】 : To answer your two questions: : 1. 解析方法 is the reason of your maintenance issue. Your formula need to : change when devices change. Numerical analysis seem more promising. : 2. My computer science knowledge only tells me Newton-Raphson method - : which is numerical analysis, not symbolic analysis. You might need some : special library to do the symbolic analysis.
|
p***o 发帖数: 1252 | 7 There is a book called Circuit Simulation by Farid N. Najm.
It contains almost everything you need to know to build a practical
simulator for non-linear PDEs, not to mention the relationship
between thermal elements and their electronic counterparts
(e.g. conductance/capacitance, temperature vs. voltage).
Once you know how to build a simulator, you'll have better idea
on building optimization tools - at least you can use some
probabilistic metaheuristics like simulated annealing and
evolutionary algorithms.
So the bottom line is you can do it, though it may take you
quite a few month or years before you can get some results.
【在 f*******r 的大作中提到】 : 我是学mechanical engineering的。现在准备用C++算一个thermal system的优化问题 : 。所以想来这里向各位高手请教。 : 首先,为什么用C++? : 1. 以前用Fortran 编程作数值计算,但是每次thermal system 一点小改动,我的 : Fortran 程序就要改好多,所以就想用C++。 : 2。Thermal system的每一个部件,象冷水机组,冷却塔,水泵,换热器等等,正好可 : 以用class描述,然后整个系统用由这些classes组成的一个新类来描述。这样很符合面 : 向对象的思路。 : 我的问题是这个程序主要结构应该怎么样? : 在说这个问题之前,再来说说thermal system的优化问题做什么。我们知道每一个部件
|
p***o 发帖数: 1252 | 8 Symbolic analysis could be as easy as representing x^3+2x+1
as an array of tuples ((1,3),(2,1),(1,0)) and computing its
derivative as ((3,2),(2,0)). One easy idea is too design
a template to hold all possible functions and design rules
to handle it.
【在 f*******r 的大作中提到】 : : 多些兄台的指点。我想你说的symbolic analysis,正是我想要的。从来没有接触过这 : 方面的编程,不知道哪里能找到这方面的信息。
|
a****l 发帖数: 8211 | 9 why don't you you something like matlab?
【在 f*******r 的大作中提到】 : 我是学mechanical engineering的。现在准备用C++算一个thermal system的优化问题 : 。所以想来这里向各位高手请教。 : 首先,为什么用C++? : 1. 以前用Fortran 编程作数值计算,但是每次thermal system 一点小改动,我的 : Fortran 程序就要改好多,所以就想用C++。 : 2。Thermal system的每一个部件,象冷水机组,冷却塔,水泵,换热器等等,正好可 : 以用class描述,然后整个系统用由这些classes组成的一个新类来描述。这样很符合面 : 向对象的思路。 : 我的问题是这个程序主要结构应该怎么样? : 在说这个问题之前,再来说说thermal system的优化问题做什么。我们知道每一个部件
|
t****t 发帖数: 6806 | 10 symbolic analysis跟编程语言关系不大, 主要是算法. 我记得matlab用的是maple的核
心. 自己写一个代价比较大, 而且也容易出错. 你不如也用maple的核心好了, 我听说
有c++/fortran/java界面的.
【在 f*******r 的大作中提到】 : : 多些兄台的指点。我想你说的symbolic analysis,正是我想要的。从来没有接触过这 : 方面的编程,不知道哪里能找到这方面的信息。
|
f*******y 发帖数: 988 | 11 正解
不过symbolic运算首选Mathematica
完全没必要用C++
【在 t****t 的大作中提到】 : symbolic analysis跟编程语言关系不大, 主要是算法. 我记得matlab用的是maple的核 : 心. 自己写一个代价比较大, 而且也容易出错. 你不如也用maple的核心好了, 我听说 : 有c++/fortran/java界面的.
|
t****t 发帖数: 6806 | 12 他如果是符号/数值混合的话, mathematica也可以吗? 数值运算够快吗?
其实对速度要求不高还不如matlab呢...
【在 f*******y 的大作中提到】 : 正解 : 不过symbolic运算首选Mathematica : 完全没必要用C++
|