root/trunk/EBaporate/shorts.c

Revision 449, 3.8 kB (checked in by hazelsct, 6 years ago)

Separated shorts.c into new file, documented it. Other doc changes.

  • Property svn:keywords set to Author Date Id Revision
Line 
1/***************************************
2  $Header$
3
4  This file has lots of little functions ("shorts") to do simple tasks which
5  one might want to modify, such as beam patterns, thermal and evaporative
6  heat loss functions and beam penetration depth.  The best ``documentation''
7  for these little functions is probably the source code itself, especially
8  since they were written at a time when I thought, ``The more code we can get
9  on the screen at once, the better!''.
10***************************************/
11
12#include "ebsurf.h"
13
14/*************** Time-dependent generation functions ***************/
15
16/* The standard "pattern": one beam strike at t=3tres */
17double gtnorm (double t, struct param *p)
18{ return exp(-(2*t/p->tres-3)*(2*t/p->tres-3)); } /* Normal version */
19
20/* Lissidue pattern, different frequency & waveform oscillations in x and y */
21/* Sine wave for lissidue pattern */
22double sino(double t, double freq)
23{ return sin(2*M_PI*t*freq); }
24/* Triangle wave for lissidue pattern */
25double triang(double t, double freq)
26{ return _ABS((t*freq-floor(t*freq))*4-2)-1; }
27/* Sawtooth wave for lissidue pattern */
28double sawt(double t, double freq)
29{ return (t*freq-floor(t*freq))*2-1; }
30/* Then the pattern generator itself */
31double gtliss(double t, struct param *p)
32{
33  double x,y;
34  x=p->plen/2*p->xpat(t,p->xfrq)-p->x;
35  y=p->pwid/2*p->ypat(t,p->yfrq)-p->y;
36  return exp(-4*x*x/p->spx/p->spx-4*y*y/p->spy/p->spy);
37}
38
39/* Adam Powell's innovative disk pattern for a circular hearth/mold */
40double gtdisk(double t, struct param *p)
41{ double x,y;
42  x=.25*p->plen*(cos(2.*M_PI*t*p->xfrq)+cos(2.*M_PI*t*p->yfrq))-p->x;
43  y=.25*p->pwid*(sin(2.*M_PI*t*p->xfrq)+sin(2.*M_PI*t*p->yfrq))-p->y;
44  return exp(-x*x/p->spx/p->spx-y*y/p->spy/p->spy); }
45
46/************ Thermal and evaporation and beam functions ***********/
47
48/* Radiation heat loss */
49double radloss(double T, struct param *p)
50{ return p->eps * SIGMA * (T*T*T*T - p->Tenv*p->Tenv*p->Tenv*p->Tenv); }
51
52/* Evaporation flux, (moles/cm^2/second) */
53double vloss(double T, double E, double A, double C, double D)
54{ return E*exp(-A/T+C*log(T)+D*T); }
55
56/* Aluminum k'' value */
57double vloss2(double T, double E, double A, double C, double D)
58{ return 8.2924243e-5 * exp (log(10.)*(-16450./T+12.36) - 1.523*log(T)); }
59
60/* dVapFlux/dTsurf (moles/cm^2/second/K) */
61double vlossder(double T, double E, double A, double C, double D)
62{ return E * (A/T/T+C/T+D) * exp(-A/T+C*log(T)+D*T); }
63
64/* Total radiative + evaporative heat losses (erg/cm^2/second) */
65double loss(double T, struct param *p)
66{
67  return radloss (T,p) +
68    p->Q0*exp(p->S*T) * vloss (T,p->E,p->A,p->C,p->D);
69}
70
71/* Derivative of total heat loss wrt. surf temperature (erg/cm^2/second/K) */
72double lossder (double T, struct param *p)
73{ return 4*p->eps*SIGMA*T*T*T +
74    p->Q0*exp(p->S*T) * vlossder(T,p->E,p->A,p->C,p->D) +
75    p->Q0*p->S*exp(p->S*T) * vloss(T,p->E,p->A,p->C,p->D); }
76
77/* Calculate the beam penetration depth in g/cm^2 (divide by density to get the
78   actual depth) as a function of voltage (kV).  This uses a line segment fit
79   to the log-log curve given by Schiller Electron Beam Technology, p. 39:
80   10  keV -> .00026 g/cm^2 -> .000063 cm in titanium
81   30  keV -> .0020  g/cm^2 -> .00049 cm
82   100 keV -> .015   g/cm^2 -> .0036 cm
83   300 keV -> .082   g/cm^2 -> .020 cm
84   1   MeV -> .40    g/cm^2 -> .10 cm */
85#define logfit(x,x1,x2,y1,y2) \
86  exp(log(y1)+(log(y2)-log(y1))*(log(x)-log(x1))/(log(x2)-log(x1)))
87double depvolt(volts) double volts;
88{ void errer();
89  if(volts<10) errer("No data available for energy below 10 kV.");
90  if(volts<30) return logfit(volts,10,30,.00026,.002);
91  if(volts<100) return logfit(volts,30,100,.002,.015);
92  if(volts<300) return logfit(volts,100,300,.015,.082);
93  if(volts<=1000) return logfit(volts,300,1000,.082,.4);
94  errer("No data available for energy above 1 MV."); }
95#undef logfit
Note: See TracBrowser for help on using the browser.