简体   繁体   English

在MATLAB中求解非线性有限元

[英]Solving nonlinear FEM in MATLAB

I try to solve a heat diffusion problem on tetrahedral finite elements with nodal heat sources, which depend on the solution vector, in MATLAB. 我试图解决带有节点热源的四面体有限元的热扩散问题,该问题取决于解矢量,在MATLAB中。 The nonlinear equation system looks like this: 非线性方程组如下所示:

B U' + A U = q(T) B U'+ A U = q(T)

with B being the heat capactiy matrix, A being the conductivity matrix, q being the source terms and U being the Temperature. B是热容矩阵,A是电导率矩阵,q是源项,U是温度。 I use an Adams-Bashforth/Trapezoid Rule predictor-corrector scheme with a Picard iteration followed by a time step control. 我将Adams-Bashforth /梯形规则预测器-校正器方案与Picard迭代配合使用,然后进行时间步长控制。 The temperature for the source terms is evaluated exactly between the last time step's temperature and the predictor's temperature. 在最后一个时间步的温度和预测变量的温度之间精确评估源项的温度。 Here is a simplified version of the predictor-corrector code. 这是预测器-校正器代码的简化版本。 The calculation of the sources is a function. 源的计算是一个函数。

    % predictor
    K0 = t(n)-t(n-1);              
    Upre(dirichlet) = u_d_t(coordinates(dirichlet,:));
    Upre(FreeNodes) = U(FreeNodes,n) + (dt/2)*((2+dt/K0)*U_dt(FreeNodes,3) - (dt/K0)*U_dt(FreeNodes,1));      % predictor step
    Uguess = Upre;     % save as initial guess for Picard iteration

    % corrector with picard iteration
    while res >= picard_tolerance 
        T_theta = Uguess*theta + (1-theta)*U(:,n);
        b = q(T_theta);
        % Building right-hand side vector (without Dirichlet boundary conditions yet)
        rhs = ((2/dt)*B*U(:,n) + B*U_dt(:,1))+b;

        % Applying Dirichlet Boundary Conditions to the Solution Vector
        Ucor(dirichlet) = u_d_t(coordinates(dirichlet,:));
        rhs = rhs - ((2/dt)*B+A)*Ucor;

        % Solving the linearized system using the backslash operator
        % P*U(n+1) = f(Un) => U(n+1) = P\f(Un)
        Ucor(FreeNodes) = ((2/dt)*B(FreeNodes,FreeNodes)+A(FreeNodes,FreeNodes))\rhs(FreeNodes);
        res = norm(Uguess-Ucor);
        Uguess = Ucor;
        U(:,n+1) = Ucor;
    end

As you can see I use the backslash operator to solve the system. 如您所见,我使用反斜杠运算符来求解系统。 The non-linearity of the system should not be to bad. 系统的非线性不应该太坏。 However, with increasing time steps the picard method converges more slowly and eventually stops to converge altogether. 但是,随着时间步长的增加,皮卡德方法收敛速度变慢,最终完全停止收敛。 I need much bigger time steps though, so I put the whole corrector step into a function and tried to solve it with fsolve instead to see if I achieve quicker convergence. 但是,我需要更大的时间步长,因此我将整个校正器步长放入函数中,并尝试使用fsolve解决它,以查看是否实现了更快的收敛。 Unfortunately fsolve seems to never even finish the first time step. 不幸的是,fsolve似乎从未完成第一步。 I suppose I did not configure the options for fsolve correctly. 我想我没有正确配置fsolve选项。 Can anyone tell me, how to configure fsolve for large sparse nonlinear systems ( We are talking about thousands upt to hundredthousands of equations). 谁能告诉我,如何为大型稀疏非线性系统配置fsolve(我们正在谈论成千上万的方程式)。 Or is there maybe a better solution than fsolve for this problem? 还是有比解决这个问题更好的解决方案? Help and - as I am not an expert or computational engineer - explicit advice is greatly appreciated! 帮助和-因为我不是专家或计算机工程师-明确的建议非常感谢!

In my experience, non-linear equations are solved by linearizing to solve for a temperature increment and iterating to convergence using something like Newton Raphson solver. 以我的经验,非线性方程是通过线性化来求解温度增量并使用诸如Newton Raphson求解器之类的方法迭代收敛的。 So if you're using an implicit integration schema, you have an outer time step solution with an inner non-linear solution for the temperature step over the time step. 因此,如果您使用隐式积分架构,那么您将获得外部时间步长解决方案,以及针对时间步长上的温度步长的内部非线性解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM