-
Notifications
You must be signed in to change notification settings - Fork 0
/
maier_saupe.c
57 lines (44 loc) · 933 Bytes
/
maier_saupe.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*
Critical temperature in Maier-Saupe theory
s = -0.5 + 1.5 * z'(m)/z(m) => (1)
s = 2*k*T*m/(3*u) => (2)
At Tc there will be exactly one root for (1) - (2)
*/
#include<stdio.h>
#include<math.h>
#include "newton_raphson.h"
#include "gsl/gsl_sf_erf.h"
double z(double, void*);
double ms(double, void*);
int main()
{
double a = 6.0;
double x;
void *params;
params = &a;
/*while (a<4.0)
{*/
x = newton_raphson(100.0,1.0e-6, &ms ,params);
printf("a = %f, x= %e\n", a, x);
/* a+=0.01;
}*/
return 0;
}
double z(double m, void *params)
{
double ans;
double sqrtm;
double pi;
pi = 4.0 * atan(1.0);
sqrtm = sqrt(m);
ans = sqrt(pi) * gsl_sf_erf(sqrtm) / (2.0 * sqrtm);
return ans;
}
double ms(double m, void *params)
{
double ans;
double *a; /* a = u/(kT) */
a = (double *)params;
ans = -0.5 + (1.5 * derivative(m,1e-4,&z,NULL)/ z(m,NULL)) - (2.0*m/(3.0*(*a)));
return ans;
}