Screamer Project  V3.3.1
Screamer Structure
 All Files Functions Variables
pwlfunc.f
Go to the documentation of this file.
1  function fpiecewiselinear (time, npts, pts, ltime)
2 c
3 c Define passed variables
4 c
5  integer npts, ltime
6  real time, pts(npts)
7 c
8  parameter(almost0 = 1.0e-12)
9  parameter(ralmost0 = 1.0 / almost0)
10 c
11 c Change log
12 c
13 c 2014-02-06 RBS: Changed real*4 to real
14 c 2014-05-02 RBS: Changed integer*4 to integer
15 c
16 c Interpolates with a piecewise linear function using time as the independent
17 c variable. pts(i) i=1,3,5,... are the independent variable parameters
18 c and pts(j) j=2,4,6,... are the dependent variable parameters.
19 c npts is at least 4 and is an even integer.
20 c pts(1) < pts(3) < pts(5) ... .
21 c ltime is an integer that points to the last independent variable in
22 c points which the previous time was less than (speeds the lookup)
23 c (note that we are assuming that each time this is called for a particular
24 c circuit element section, the time has increased).
25 c Set ltime=0 if this is the first call.
26 c
27 c Find the endpoints for the independent variable.
28 c
29  if ((time .lt. pts(1)) .or. (time .gt. pts(npts-1))) then
30  fpiecewiselinear = 0.0
31  ltime = 0
32  return
33  end if
34 c
35 c Use lasttime to set the looping.
36 c
37  if (ltime .lt. 3) then
38  i = 3
39  else
40  i = ltime
41  end if
42  time1 = pts(i-2)
43  time2 = pts(i)
44 c
45 c Set the index to the point in the table which brackets the current time.
46 c
47  do while ((time .lt. time1) .or. (time .gt. time2))
48  i = i + 2
49  time1 = time2
50  time2 = pts(i)
51  end do
52 c
53 c Set the time difference of the two table points and set the time incremented
54 c since the first table time point.
55 c Then interpolate to find the function.
56 c
57  tdiff = amax1((time2-time1), almost0)
58  tdel = time - time1
59  slope = (pts(i+1) - pts(i-1)) / tdiff
60  fpiecewiselinear = pts(i-1) + tdel*slope
61 c
62  ltime = i
63 c
64  return
65  end
function fpiecewiselinear(time, npts, pts, ltime)
Definition: pwlfunc.f:1
c *****************************************************************************c Various format statements for read_screamer_data output c To get these into made format to be characters c for each line corrected spelling errors in format added statement for Zflow Plasma Loss Model added format for CSV output type fixed more lines longer than characters added format for Measure Zflow Block and forward c reverse current directions in Zflow plasma loss c and Zflow POS models added format for SFC output type c removed from all code calls c c c c c a80 c i10 c No grids on plots c Do not write files containing the plotted points c Execute only one cycle c Do not echo the setup parameters and indicies c c &exitting c a13 c c c c c c c c102 c &described as a function of time c c c &described as a function of time c c c &function of time c c shell c &min A K c &trapped field time
Definition: zdemfmt.h:85