Changeset 443

Show
Ignore:
Timestamp:
03/16/2009 08:48:37 PM (3 years ago)
Author:
powell
Message:

New rectangle bookkeeping functions.

Location:
trunk/matml/src/ternary
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/matml/src/ternary/book.c

    r442 r443  
    8686 
    8787/*++++++++++++++++++++++++++++++++++++++ 
     88  This initializes the compositions 
     89  +latex+$C_2$ and $C_3$ 
     90  -latex-C2 and C3 
     91  in an array of points filling a rectangle between (A2,A3), (B2,B3) in 
     92  composition space.  It also sets the 
     93  +latex+{\tt efunc}, $T$ and $P$ 
     94  +html+ <tt>efunc</tt>, <i>T</i> and <i>P</i> 
     95  fields of each point to -1 to indicate that free energies and derivatives are 
     96  not yet calculated.  This is of course trivial compared with the triangle 
     97  case. 
     98 
     99  int init_rect_array It returns zero or an error code. 
     100 
     101  int res2 Resolution of the discretization (number of intervals) in the 
     102  +latex+$C_2$-direction. 
     103  -latex-C2-direction. 
     104 
     105  int res3 Resolution of the discretization (number of intervals) in the 
     106  +latex+$C_3$-direction. 
     107  -latex-C3-direction. 
     108 
     109  ternary_point *points Array of ternary points of size 
     110  +latex+({\tt res2}+1)$\times$({\tt res3}+1). 
     111  -latex-(res2+1) * (res3+1). 
     112 
     113  int efunc Energy function index indicating which energy curve this point will 
     114  be on. 
     115 
     116  double A2 Minimum value of 
     117  +latex+$C_2$. 
     118  -latex-C2. 
     119 
     120  double A3 Minimum value of 
     121  +latex+$C_3$. 
     122  -latex-C3. 
     123 
     124  double B2 Maximum value of 
     125  +latex+$C_2$. 
     126  -latex-C2. 
     127 
     128  double B3 Maximum value of 
     129  +latex+$C_3$. 
     130  -latex-C3. 
     131  ++++++++++++++++++++++++++++++++++++++*/ 
     132 
     133int init_rectangle_array 
     134(int res2, int res3, ternary_point *points, int efunc, 
     135 double A2, double A3, double B2, double B3) 
     136{ 
     137  int i,j; 
     138 
     139  for (i=0; i<=res2; i++) 
     140    for (j=0; j<=res3; j++) 
     141      { 
     142        points [j*(res2+1)+i].C2 = A2 + (B2-A2) * ((double) i/res2); 
     143        points [j*(res2+1)+i].C3 = A3 + (B3-A3) * ((double) j/res3); 
     144        points [j*(res2+1)+i].efunc = efunc; 
     145        points [j*(res2+1)+i].T = points [j*res2+i].P = -1; 
     146      } 
     147 
     148  return 0; 
     149} 
     150 
     151 
     152/*++++++++++++++++++++++++++++++++++++++ 
    88153  This function fills an array with vertex indices. 
    89154 
    90155  int init_triangle_vertices It returns zero or an error code. 
    91156 
    92   int resolution Resolution of the discretization (number of points on a side). 
     157  int resolution Resolution of the discretization (number of intervals on a 
     158  side). 
    93159 
    94160  int *vertex_array Array of triangle indices of size 
     
    125191  vertex_array [3*index+1] = offset + ROWSTART(resolution-1)+1; 
    126192  vertex_array [3*index+2] = offset + ROWSTART(resolution); 
     193 
     194  return 0; 
     195} 
     196 
     197 
     198/*++++++++++++++++++++++++++++++++++++++ 
     199  This function fills an array with triangle vertex indices, two triangles per 
     200  rectangular cell. 
     201 
     202  int init_rectangle_vertices It returns zero or an error code. 
     203 
     204  int res2 Resolution of the discretization (number of intervals) in the 
     205  +latex+$C_2$-direction. 
     206  -latex-C2-direction. 
     207 
     208  int res3 Resolution of the discretization (number of intervals) in the 
     209  +latex+$C_3$-direction. 
     210  -latex-C3-direction. 
     211 
     212  int *vertex_array Array of triangle indices of size 
     213  +latex+2$\times${\tt res2$\times$res3}. 
     214  -latex-2 * res2 * res3. 
     215 
     216  int offset Constant to add to vertex indices, usually 0. 
     217  ++++++++++++++++++++++++++++++++++++++*/ 
     218 
     219int init_rectangle_vertices (int res2, int res3, int *vertex_array, int offset) 
     220{ 
     221  int i,j; 
     222 
     223  for (i=0; i<res2; i++) 
     224    for (j=0; j<res3; j++) 
     225      { 
     226        vertex_array [(j*res2+i)*6]   = offset + j*(res2+1)+i; 
     227        vertex_array [(j*res2+i)*6+1] = offset + j*(res2+1)+i+1; 
     228        vertex_array [(j*res2+i)*6+2] = offset + (j+1)*(res2+1)+i; 
     229 
     230        vertex_array [(j*res2+i)*6+3] = offset + j*(res2+1)+i+1; 
     231        vertex_array [(j*res2+i)*6+4] = offset + (j+1)*(res2+1)+i+1; 
     232        vertex_array [(j*res2+i)*6+5] = offset + (j+1)*(res2+1)+i; 
     233      } 
    127234 
    128235  return 0; 
  • trunk/matml/src/ternary/ChangeLog

    r439 r443  
    1212  * Added spinodal.c with calc_spinodal function returning a phase_boundary. 
    1313  * New "square" free energy parameters for pseudo-square representation. 
     14  * Rectangle bookkeeping functions complete square functionality. 
    1415 
    1516 -- 
  • trunk/matml/src/ternary/freenergy.c

    r439 r443  
    212212    eparams->R*T*(((C2+C3>=1) ? LOCAL_INFINITY : eparams->S1/C1) 
    213213                  + ((C2<=0.) ? LOCAL_INFINITY : eparams->S2/C2) 
    214                   + ((C2>=1.) ? LOCAL_INFINITY : 
    215                      eparams->S4/(1.-C2))) 
     214                  + ((C2>=1.) ? LOCAL_INFINITY : eparams->S4/(1.-C2))) 
    216215    - eparams->Omega12*2 - eparams->Omega123*2*C3; 
    217216} 
     
    258257    eparams->R*T*(((C2+C3>=1) ? LOCAL_INFINITY : eparams->S1/C1) 
    259258                  + ((C3<=0.) ? LOCAL_INFINITY : eparams->S3/C3) 
    260                   + ((C3>=1.) ? LOCAL_INFINITY : 
    261                      eparams->S5/(1.-C3))) 
     259                  + ((C3>=1.) ? LOCAL_INFINITY : eparams->S5/(1.-C3))) 
    262260    - eparams->Omega13*2 - eparams->Omega123*2*C2; 
    263261}