自动分化 [英] Automatic differentiation

查看:136
本文介绍了自动分化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究我的毕业项目,特别是关于流体动力学的问题,我有一个非线性方程组来解决,我选择了牛顿方法,所以我必须通过matix的雅可比行列式(实际上是12x12矩阵)。这个矩阵中的每个元素都是在某个点评估的函数的导数,所以手动编写所有这些并计算每个导数是非常困难的。系统看起来像:


f 1 (x 1 ,x 2 , x 3 ,...,x 12 )= 0

f 2 (x 1 >,x 2 ,x 3 ,...,x 12 )= 0







f 12 (x 1 ,x 2 ,x 3 ,..., x 12 )= 0




其中x 1 ,x 2 ,x 3 是变量(温度,压力...等)

我可以自动执行此操作吗?如果在Fortran中不可行,我可以使用其他脚本语言作为Python(sympy模块)吗? 解决方案

是的,通过使用一个适当的算法差异化包。这是一种可以评估(原则上)任意函数派生程序的方法,您可以使用计算机程序来表示任何函数的派生程序,并且Fortran中有许多软件包。看看



http:// en。 wikipedia.org/wiki/Automatic_differentiation



http://www.nag.co.uk/pss/nag-and-algorithmic-differentiation



开始使用



免责声明:

1)我从来没有在愤怒中使用过它。2)直到最近我还为NAG工作过。


I am working on my project of graduating, particularly, about fluid dynamics and I have a system of non-linear equations to solve, I choose the Newton's method so I have to pass through the Jacobian of the matix (actually 12x12 matrix). Every element in this matrix is the derivative of the function evaluated at some point, it's very difficult to write all of these manually and calculate each derivative; the system looks like:

f1 (x1, x2, x3, ..., x12) = 0
f2 (x1, x2, x3, ..., x12) = 0
.
.
.
f12 (x1, x2, x3, ..., x12) = 0


Where x1, x2, x3 are the variables (Temperature, pressure ...etc)
Can I automate this operation? If it's not possible in Fortran, can I use other scripting languages as Python (sympy module)?

解决方案

Yes, by use of an appropriate algorithmic differentiation package. This is a method which can evaluate (in principle) arbitrary order derivatives of any function you have expressed as a computer program, and a number of packages exist for Fortran. Take a look at

http://en.wikipedia.org/wiki/Automatic_differentiation

and

http://www.nag.co.uk/pss/nag-and-algorithmic-differentiation

to get started

Disclaimers:

1) I have never used it "in anger"

2) Until recently I worked for NAG

这篇关于自动分化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆