HP Forums
Complex Flow Study - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Software Libraries (/forum-10.html)
+--- Forum: HP-41C Software Library (/forum-11.html)
+--- Thread: Complex Flow Study (/thread-21413.html)



Complex Flow Study - Ángel Martin - 03-07-2024 09:45 AM

Greetings fellow forum members,

The Contour Integration thread is a good example of doing HP-41 versions for advanced HP-15 programs. The next one in the advanced functions handbook is the Complex Potentials, and the program below is my take at an HP-41 version based on the original one.

Design differences:

I've used an X-Mem data file to store the results, which seemed more a appropriate than a matrix since there are no matrix operations involved (and obviously removes the need for the Advantage/SandMatrix). Besides, the SOLVE engine used is from the 'Solve & Integrate ROM" - a leaner module that avoids the need for said Advantage/SandMatrix.

The complex potential function is programmed under its own global label, which in the example is LBL "PZ", integrated in the same code stream. Obviously the 41Z module is required.

Finally, I used a couple of functions from the AMC_OS/X for data entry as a convenience, like PMTA to input the function name in ALPHA, and PMTK to choose whether the streamlines or the velocity equipotential lines are to be calculated.

You should refer to the original description for details.

Code:
01  LBL "ZFLOW"
02  "FNAME? "
03  PMTA
04  ASTO 08
05  "#N=?"          number of points
06  PROMPT
07  STO 09
08  "H=?"           step size
09  PROMPT
10  STO 04
11  "Z0=? (IM^RE)"  reference point
12  PROMPT
13  ZSTO 00
14  "TYPE? SV"       streamlines / velocities
15  PMTK
16  CF 00            default: streamlines
17  2
18  X=Y?             velocity?
19  SF 00            yes, flag if    
20  LBL C            runtime repeats
21  RCL 09           n
22  ST+ X            2n
23  "ZFL"            data file name
24  SF 25            in case already exists
25  PURFL            clean slate
26  CF 25
27  CRFLD            create file
28  CLX            
29  SEEKPTA          reset pointer
30  RCL 09           n
31  1        
32  -                n-1
33  E3
34  /                0,00(n-1)    
35  1
36  +                1,00(n-1)
37  STO 07           index register
38  ZRCL 00          z0
39  STO 02           Re(z0)
40  SAVEX
41  X<>Y             Im(z0))
42  STO 03
43  SAVEX
44  X<>Y             z0
45  XEQ IND 08       calculates Im(P(z0))
46  STO 05           save it as constant
47  LBL 02
48  RCL 04           h
49  RCL 07           k,00(n-1)
50  INT              k
51  *                h.k
52  RCL 02           Xk
53  +                X(k-1)=Xk+k.h
54  STO 06
55  RCL 03           Yk
56  ENTER^           duplicate limit
57  FROOT            solve for y(k+1)
58  GTO 04           root found
59  4                not found, adjust        
60  ST/ 04           h=h/4
61  ST* 07           n=4.n
62  GTO 02           try again
63  LBL 04           root found
64  RCL 06           x(k+1)
65  VIEW X
66  SAVEX            save result
67  RDN              y(k+1)
68  STO 03           update value
69  VIEW X
70  SAVEX            save result
71  ISG 07           increment index
72  GTO 02           do next point
73  CLX              all done
74  SEEKPT           reset pointer 
75  RTN              done.
76  LBL "ZFL"        function to SOLVE
77  RCL 06           x(k+1)
78  XEQ IND 08       calculates Im(P(zk))
79  RCL 05           constant
80  -                subtracted                
81  RTN              done
82  LBL "PZ"         Complex Potential
83  ZENTER^          duplicate zk in W
84  ZINV             1/zk
85  Z+               zk+1/zk
86  FC? 00           sreamlines?
87  X<>Y             yes, take imaginary part
88  END              done.

Cheers,
ÁM