Showing posts with label sun altitude. Show all posts
Showing posts with label sun altitude. Show all posts

Thursday, July 6, 2017

Fun With the HP 42S

Fun With the HP 42S

Previous Links:

HP 42S Programming Part I:  Matrix Column Sum, GCD, Error Function:  http://edspi31415.blogspot.com/2016/07/hp-42s-programming-part-i-matrix-column.html

HP 42S Programming Part II:  Dew Point, Ellipse Area and Eccentricity, Easy Transverse:
http://edspi31415.blogspot.com/2016/07/hp-42s-programming-part-ii-dew-point.html

HP 42S Programming Part III: Numerical Derivative, Recurring Sequences, Fractions:
http://edspi31415.blogspot.com/2016/07/hp-42s-programming-part-iii-numerical.html



HP 42S Julian Date

Given month, day, year, and university time (Greenwich), the Julian date is calculated.  For January 1, 2000 at 12:00 AM, the date is 2,451,545.5.

00 {141-Byte Prgm}
01 LBL “JULDATE”
02 “MONTH”
03 PROMPT
04 STO 01
05 “DAY”
06 PROMPT
07 STO 02
08 “4 DIGIT YEAR”
09 PROMPT
10 STO 03
11 “UT TIME”
12 PROMPT
13 STO 04
14 367
15 RCL* 03
16 STO 00
17 9
18 RCL+ 01
19 12
20 ÷
21 IP
22 RCL+ 03
23 4
24 ÷
25 7
26 *
27 IP
28 STO -00
29 RCL 01
30 9
31 –
32 7
33 ÷
34 RCL+ 03
35 100
36 ÷
37 IP
38 3
39 *
40 4
41 ÷
42 IP
43 STO- 00
44 275
45 RCL* 01
46 9
47 ÷
48 IP
49 STO+ 00
50 RCL 02
51 STO+ 00
52 1721028.5
53 STO+ 00
54 RCL 04
55 24
56 ÷
57 STO+ 00
58 RCL 00
59 END

Example:

Input:  May 8, 2017, 03:00 UT.  Result:  2457881.6250

HP 42S Sun Approximate Declination, Altitude, and Azimuth


Input:  Days after the vernal equinox (typically March 21), Earth’s latitude (north/south), number of hours after local noon (example:  for 7 AM, enter -5.  For 7 PM, enter 7).

00 { 147-Byte Prgm }
01 LBL “SUNAA”
02 DEG
03 “DAYS AFTER EQ.”
04 PROMPT
05 STO 00
06 “LATTITUDE”
07 PROMPT
08 STO 01
09 “HRS AFTER NOON”
10 PROMPT
11 STO 02
12 0.9856
13 RCL* 00
14 SIN
15 23.45
16 *
17 STO 04
18 COS
19 RCL 01
20 COS
21 *
22 15
23 RCL* 02
24 COS
25 *
26 RCL 01
27 SIN
28 RCL 04
29 SIN
30 *
31 +
32 ASIN
33 STO 05
34 SIN
35 RCL 01
36 SIN
37 *
38 RCL 04
39 SIN
40 –
41 RCL 05
42 COS
43 RCL 01
44 COS
45 *
46 ÷
47 ACOS
48 STO 06
49 RCL 04
50 “DECLINATION”
51 AVIEW
52 STOP
53 RCL 05
54 “ALTITUDE”
55 AVIEW
56 STOP
57 RCL 06
58 “AZIMUTH”
59 AVIEW
60 END


Example:

Input:  100 days after the vernal equinox, 43.72° N, about 12 noon (T = 0)
Results:  Declination ≈ 23.1888°, Altitude:  69.4688°, Azimuth: 0.0002°

 HP 42S Chebyshev Polynomial

The trigonometric definition is used to calculate T_n(x):

For |x| > 1, cosh (n * acosh x)
For |x| ≤ 1, cos (n * acos x)

00 {42-Byte Prgm}
01 LBL “CHEBY”
02 “N”
03 PROMPT
04 STO 00
05 “X”
06 PROMPT
07 STO 01
08 ABS
09 1
10 X≥Y?
11 GTO 00
12 RCL 01
13 ACOSH
14 RCL* 00
15 COSH
16 GTO 01
17 LBL 00
18 RCL 01
19 ACOS
20 RCL* 00
21 COS
22 LBL 01
23 END

Examples:

T_4(2) (n = 4, x = 2).  Result:  97

T_4(0.5)  (n = 4, x = 0.5)  Result:  -0.5

HP 42S Pulley

There are two weights in a pulley system, held by a rope has a negligible contribution.  The program uses SI units (kg, m, s, with g = 9.80665 m/s^2).  The simultaneous equations solve for acceleration (m/s^2) and tensions:

T – m1 * a = m1 * g
T + m2 * a = m2 * g

Source:  HP 22S Science Student Applications.  Edition 1.  Corvallis, Oregon.  May 1988

00 {161-Byte Prgm}
01 LBL “PULLEY”
02 “MASS 1 (KG)”
03 PROMPT
04 STO 01
05 “MASS 2 (KG)”
06 PROMPT
07 STO 02
08 9.80665
09 STO 00
10 2
11 ENTER
12 2
13 DIM “MAT1”
14 INDEX “MAT1”
15 1
16 STOEL
17 J+
18 RCL 01
19 +/-
20 STOEL
21 2
22 ENTER
23 1
24 STOIJ
25 1
26 STOEL
27 J+
28 RCL 02
29 STOEL
30 2
31 ENTER
32 1
33 DIM “MAT2”
34 INDEX “MAT2”
35 RCL 00
36 RCL* 01
37 STOEL
38 I+
39 RCL 00
40 RCL* 02
41 STOEL
42 RCL “MAT1”
43 INVRT
44 RCL “MAT2”
45 *
46 STO “MAT3”
47 INDEX “MAT3”
48 RCLEL
49 “T”
50 AVIEW
51 STOP
52 I+
53 RCLEL
54 “a”
55 AVIEW
56 END

Example:  m1 = 32 kg, m2 = 56 kg
Result:  tension = 399.3981, a = 2.6745 m/s^2

 HP 42S Rotation Matrix

R = [[ cos θ, -sin θ ],[ sin θ, cos θ ]]

00 {138-Byte Prgm}
01 LBL “ROTATE2”
02 DEG
03 “ANGLE °”
04 PROMPT
05 STO 00
06 1
07 ENTER
08 2
09 DIM “MAT1”
10 INDEX “MAT1”
11 “X0”
12 PROMPT
13 STOEL
14 J+
15 “Y0”
16 PROMPT
17 STOEL
18 2
19 ENTER
20 2
21 DIM “MAT2”
22 INDEX “MAT2”
23 RCL 00
24 COS
25 STOEL
26 J+
27 RCL 00
28 SIN
29 +/-
30 STOEL
31 2
32 ENTER
33 1
34 STOIJ
35 RCL 00
36 SIN
37 STOEL
38 J+
39 RCL 00
40 COS
41 STOEL
42 RCL “MAT1”
43 RCL “MAT2”
44 *
45 STO “MAT3”
46 INDEX “MAT3”
47 RCLEL
48 “X1”
49 AVIEW
50 STOP
51 J+
52 RCLEL
53 “Y1”
54 AVIEW
55 END

Example:
Input:  [3, -2], at an angle θ = 40°
Result:  [ 1.0126, -3.4605 ]

 Always fun working with the classic HP 42S!

Eddie

This blog is property of Edward Shore



Sunday, July 2, 2017

Fun with the Casio fx-3650p

Links to previous fx-3650p programs:

5/11/2014:


Contents:
1. Circular Sectors
2. Stopping Sight Distance
3. Resistors in Parallel
4. Net Present Value
5. Rod Pendulum
6. Vectors: Dot and Cross Products


10/27/2015:


Contents for this blog:
1.  Combination with Replacement
2.  Great Circle (Distance in km) 
3.  Orbital Speed and Period 
4.  Eccentricity and Area of an Ellipse
5.  Super Factorial
6.  Escape Velocity 
7.  Finance: Payment of a Monthly Mortgage
8.  Wind Chill Factor
9.  Speed of Sound in Dry Air 

-------

Contents for this blog entry (7/2/2017)

1.  Modulus Function
2.  Normal CDF
3.  Sum:  Σ (AX + B)^C,  from X = 0 to X = Y
4.  Sun Altitude and Azimuth Based on the Vernal Equinox
5.  Trapezoid: Midsegment, Height, and Area
6.  Solar Irradiance
7.  General a list of X Random Integers from 0 to Y

Modulus Function

Calculates A mod B for A > 0 and B > 0.   Since the fx-3650p has no integer or fraction part functions, a loop of repeated subtractions are needed.

Program (25 steps):
? → A : ? → B : Lbl 1 : A – B → A : A ≥ B Goto 1 : A

Examples:
Input:  A = 77, B = 9.  Result: 5
Input:  A = 92.38, B = 2.38.  Result:  1.94 

Normal Distribution CDF

This calculates the area of a normal distribution curve between points A and B, given that mean = 0 and deviation = 1.  Radians mode is set.  The result is stored in C.

Program (34 steps):
? → A : ? → B : Rad : ∫ ( e (-X² ÷ 2 ), A, B → C : C ÷ √ (2 π → C

Note e is the exponential function (e^x).

Examples:
Input:  A = 0, B = 2.  Result:  0.47725066
Input:  A = -1, B = 1.  Result:  0.682709924


Sum:  Σ (AX + B)^C,  from X = 0 to X = Y

Program (51 steps):
? → A : ? → B : ? → C : ? → Y : 0 → X : 0 → M : Lbl 1 : (AX + B)^C M+ : 1 + X → X : Y ≥ X Goto 1: M

Examples:
Input:  A = 2. B = 6, C = 2, Y = 4.  Result:  540
Input:  A = -3, B = 1, C = 3, Y =6.  Result:  -9632

Sun Altitude and Azimuth Based on the Vernal Equinox


Input:
Y =  days after the vernal equinox, usually March 21
A = latitude on Earth (north-south, -90° to 90°)
X = the time before solar noon, local time

For example, for 10 AM (10:00), enter 2.  For 3 PM (15:00), enter -3.  Hence:  12 – time.

Output:
D = approximate declination of the sun (-23.45° to 23.45°)
B = sun’s altitude
C = sun’s azimuth (from ground wise north)

Program (69 steps):
? → Y : ? → A : ? → X : Deg : 23.45 sin(.9856Y → D   sin¯¹ (cos A cos D cos (15X) + sin A sin D → B cos¯¹ ( ( sin B sin A – sin D) ÷ (cos A cos B → C

Examples:

Input:  Y = 90 days, A = 25°, X = -3  (3 PM)
Results: 
D = 23.44400127° = 23°26’38.4”
B = 48.81756385° = 48°49’3.23”
C = 99.85903298° = 99°51’32.52”

Input:  Y = 68 days, A = 46°, X = 4 (8 AM)
Results:
D = 21.58916369° = 21°35’20.99”
B = 35.989914° = 35°59’23.69”
C = 84.40834691° = 84°24’30.05”

Source: Sun Altitude, Azimuth, Solar Pond Absorption, HP 67/97 Energy Conservation December 1978, Author: HP

Trapezoid: Midsegment, Height, and Area


Input:
A = length of top side
B = length of bottom side
C = length of left side
D = length of right side

Output:
X = Midsegment length
Y = Height
M = Area

Program (92 steps):
? → A : ? → B : ? → C : ? → D : .5(A + B → X (-A + B + C + D)(A – B + C + D)(A – B + C – D)(A – B- C- + D) → Y : √Y ÷ ( 2 √( (B – A)² ) → Y (A + B)Y ÷ 2 → M

Example:
Input:  A = 18, B = 16, C = 12, D = 11
Results:  X = 17, Y = 9.921567417, M = 168.6666461

Source:  “Trapezoid”  Wikipedia.  Edited July 7, 2014.  Retrieved July 8, 2014

Solar Irradiance



The program calculates:



1. The solar angle of incidence given the angular elevation and azimuth (from south going “counterclockwise”:  east-north-west) of both the sun and panel.
2. The irradiance given by the solar panel. 


Input:
X = elevation of the sun
A = azimuth of the sun
Y = elevation of the solar panel
Z = azimuth of the solar panel
M = the sun’s power or irradiance.  Often this is treated as a constant, which is approximately 1367 W/m^2 for extraterrestrial solar power, or approximately 1000 W/m^2 when we are dealing with the Earth’s surface (taking scattering of light into account)

Output:
C = incidence angle
D = solar irradiance

Program (46 steps):
? → X : ? → A : ? → Y : ? → B : ? → M : Deg : cos¯¹ ( cos Y sin X + sin Y cos X cos (A – B → C M cos Y → D

Example:
Input:

Sun:
X = 55°24’21”
A = 175°15’44”

Panel:
Y = 40°
B = 90°

Sun’s Irradiance:
M = 1000 W/m

Results:
C = 48.6431686°
D = 766.0444431 W/m

Sources (you might have to copy and past these links)  

Baldocchi, Dennis “Lecture 7, Solar Radiation, Part 3, Earth-Sun Geometry”  Biometeorogy, ESPM 129  University of California, Berkeley.


Retrieved February 17, 2015. 

Mortimer, David  “Lambert’s Cosine Law”  30 January 2014.  The Solar Bucket.


Retrieved March 18, 2015

University of Oregon Solar Radiation Monitoring Laboratory  “Solar Radiation Basics”  University of Oregon.  http://solardat.uoregon.edu/SolarRadiationBasics.html   Retrieved February 10, 2015

General a list of X Random Integers from 0 to Y

This program generates a list of random integers (X) from 0 to upper limit Y.  This program uses the Fix 0 mode and makes use of the Rnd (round the number in the display) command.  Note the integers as they appear.  The program finishes by setting the calculator back in Norm 1 mode.

Program (33 steps):
? → Y : ? → X : 1 → M : Fix 0 : Lbl 1 : Ran# Y : Rnd 1 M+ : X ≥ M Goto 1 : Norm 1

Example:
Generate 5 random integers from 0 to 10.  (Y = 10, X  = 5)
Result:  6, 7, 6, 6, 10 (your results will vary)

Comments

As with the other fx-3650p I and others have posted, they can easily be adapted to the fx-50fH, fx-5800p, fx-6300g, fx-CG50, and (almost) any other Casio programming calculator. 

Recently I learned that Casio updated the fx-3650P and the fx-50F(H) with the fx-3650P II and fx-50F(H) II respectively.  The only difference I was able to spot is that the fx-3650P II now has 390 programming steps instead of 360. http://www.casio-intl.com/asia/en/calc/school/programmable/

And yes, I still wish Casio sold these models in stores in the United States.  Currently, for us U.S. residents, they can only be purchased online. 

Now if Casio made a solar version of the fx-6300g, with more memory.

Eddie


This blog is property of Edward Shore, 2017.

First Look: HP 16C Collector's Edition

 First Look: HP 16C Collector's Edition I just got the HP 16C Collector's Edition.   This is the famous HP 16C that specializes in c...