1!
2!     CalculiX - A 3-dimensional finite element program
3!              Copyright (C) 1998-2021 Guido Dhondt
4!
5!     This program is free software; you can redistribute it and/or
6!     modify it under the terms of the GNU General Public License as
7!     published by the Free Software Foundation(version 2);
8!
9!
10!     This program is distributed in the hope that it will be useful,
11!     but WITHOUT ANY WARRANTY; without even the implied warranty of
12!     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13!     GNU General Public License for more details.
14!
15!     You should have received a copy of the GNU General Public License
16!     along with this program; if not, write to the Free Software
17!     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18!
19!     d{K(X)}/dxflow
20!
21!     author: Yannick Muller
22!
23      subroutine dKdm(x,u,uprime,rpar,ipar)
24!
25      implicit none
26      integer ipar
27      real*8 x,u(1),uprime(1),rpar(*),zk0,phi,Tup,
28     &     xflow,Pup,f1_x,K_x,lambda1,df1dk,Rurd,f_k,kup
29!
30      external f_k
31!
32!     defining the parameters
33      phi=rpar(1)
34      lambda1=rpar(2)
35      zk0=rpar(3)
36      Pup=rpar(4)
37      Tup=rpar(5)
38      rurd=rpar(6)
39      xflow=rpar(7)
40      kup=rpar(8)
41!
42!     find K(X) for the given x
43
44      k_x=f_k(x,phi,lambda1,zk0,Pup,Tup,rurd,xflow,kup)
45!
46      k_x=dsqrt(K_x/x)
47!
48!     f1_x
49      f1_x= (zk0*K_x)**(7.d0/4.d0)
50     &     -(1-K_x)/dabs(1-K_x)*dabs(1-K_x)**(7d0*4d0)
51!
52!     df1dK
53      df1dK=7d0/4d0*zk0**(7d0/4d0)*K_x**(3.d0/4.d0)
54     &     +7d0/4d0*dabs(1-K_x)**(3.d0/4.d0)
55!
56!
57      uprime(1)=-x**1.6d0*lambda1*Pup**(0.8d0)
58     &     /(xflow**2*Tup**0.8d0)*f1_x+u(1)
59     &     *(lambda1*x**1.6d0*Pup**0.8d0/(xflow*Tup**0.8d0)
60     &     *df1dK-2/x)
61!
62      return
63!
64      end
65