Tuesday, April 28, 2015

HP Prime: Mechanical Engineering Programs by Djajadi Susastra

Hello everyone, still on vacation but I'm back in the Los Angeles area.  

I received an email from retired engineer Djajadi Susastra, who has been using Hewlett Packard calculators since 1989.  Susastra obtained a BSc in Mechanical Engineering that year.  He recently purchased an HP Prime calculator and has asked me to share his programs on mechanical engineering (the last three deal with business and finance), which he learned how to program the Prime from this blog.

Djajadi, I am very thankful for the compliments and with pleasure, here are the programs he has sent:


CALCULATING CROSS SECTION AREA OF CYLINDER.

EXPORT AREA()
BEGIN
LOCAL OD, ID, AA;
INPUT (OD, "OD=" );
INPUT (ID,"ID=" );
AA:=(OD^2-ID^2)/4*PI;
MSGBOX ("XSECTION AREA=" +AA);

END;


CALCULATING MAXIMUM BENDING MOMENT ON A CYLINDER AT YIELD.

EXPORT BENDING()
BEGIN
LOCAL OD, ID, YI, I, BEN;
INPUT (OD, "OD (IN)=" );
INPUT (ID, "ID= (IN)=" );
INPUT (YI, "YIELD (PSI)=");
I:=(OD^4-ID^4)/64*PI;
BEN:=YI*I/(12*(OD/2));
MSGBOX ("MAX BENDING ALLOWED (FT-LB)=" +BEN);

END;


CALCULATING COLLAPSE PRESSURE ON 110 KSI YIELD PIPE (PER API 5C3).

EXPORT COLLAPSE110()
BEGIN
LOCAL OD, ID, YI, TEN, DT, COL;
INPUT (OD, "OD (IN)=" );
INPUT (ID, "ID= (IN)=" );
YI:=110000;

DT:=OD/((OD-ID)/2);

IF DT≤12.44 THEN
COL:=2*YI*(DT-1)/DT^2;
MSGBOX ("COLLAPSE PRESS (PSI)=" +COL);
END;

IF 12.44<DT AND DT≤20.41 THEN
COL:=YI*(3.181/DT-.0819)-2852;
MSGBOX ("COLLPASE PRESS (PSI)=" +COL);
END;

IF 20.41<DT AND DT≤26.22 THEN
COL:=YI*(2.066/DT-.0532);
MSGBOX ("COLLAPSE PRESS (PSI)=" +COL);
END;

IF 26.22<DT AND DT≤1000 THEN
COL:=46950000/(DT*(DT-1)^2);
MSGBOX ("COLLAPSE PRESS (PSI)=" +COL);
END;

IF DT≥1001 THEN
MSGBOX ("NO CASE");

END;
END;

CALCULATING COLLAPSE PRESSURE ON 80 KSI YIELD PIPE (PER API 5C3).

EXPORT COLLAPSE80()
BEGIN
LOCAL OD, ID, YI, TEN, DT, COL;
INPUT (OD, "OD (IN)=" );
INPUT (ID, "ID= (IN)=" );
YI:=80000;

DT:=OD/((OD-ID)/2);

IF DT≤13.38 THEN
COL:=2*YI*(DT-1)/DT^2;
MSGBOX ("COLLAPSE PRESS (PSI)=" +COL);
END;

IF 13.38<DT AND DT≤22.47 THEN
COL:=YI*(3.071/DT-.0667)-1955;
MSGBOX ("COLLPASE PRESS (PSI)=" +COL);
END;

IF 22.47<DT AND DT≤31.02 THEN
COL:=YI*(1.998/DT-.0434);
MSGBOX ("COLLAPSE PRESS (PSI)=" +COL);
END;

IF 31.02<DT AND DT≤1000 THEN
COL:=46950000/(DT*(DT-1)^2);
MSGBOX ("COLLAPSE PRESS (PSI)=" +COL);
END;

IF DT≥1001 THEN
MSGBOX ("NO CASE");

END;
END;

CALCULATING COLLAPSE PRESSURE ON 75KSI YIELD PIPE (PER API 5C3).


EXPORT COLLAPSE75()
BEGIN
LOCAL OD, ID, YI, TEN, DT, COL;
INPUT (OD, "OD (IN)=" );
INPUT (ID, "ID= (IN)=" );
YI:=75000;

DT:=OD/((OD-ID)/2);

IF DT≤13.6 THEN
COL:=2*YI*(DT-1)/DT^2;
MSGBOX ("COLLAPSE PRESS (PSI)=" +COL);
END;

IF 13.6<DT AND DT≤22.91 THEN
COL:=YI*(3.054/DT-.0642)-1806;
MSGBOX ("COLLPASE PRESS (PSI)=" +COL);
END;

IF 22.91<DT AND DT≤32.05 THEN
COL:=YI*(1.99/DT-.0418);
MSGBOX ("COLLAPSE PRESS (PSI)=" +COL);
END;

IF 32.05<DT AND DT≤1000 THEN
COL:=46950000/(DT*(DT-1)^2);
MSGBOX ("COLLAPSE PRESS (PSI)=" +COL);
END;

IF DT≥1001 THEN
MSGBOX ("NO CASE");

END;
END;


CALCULATING VON MISSES STRESS (THICK WALL, SHIGLEY AND MITCHELL, API 6A)

EXPORT EQUI_STRESS()
BEGIN
LOCAL OD, ID, P, S1, S2, S3, SE, T;

INPUT (OD, "OD (IN)=" );
INPUT (ID, "ID= (IN)=" );
INPUT (P, "PRESSURE (PSI)=");

T:=(OD-ID)/2;
LOCAL RA;
RA:=OD/40;

IF T>RA THEN
S1:=P*ID^2/(OD^2-ID^2);
S2:=P*(OD^2+ID^2)/(OD^2-ID^2);
S3:=-1*P;
SE:=(((S1-S2)^2+(S2-S3)^2+(S3-S1)^2)/2)^.5;
MSGBOX ("EQUIVALENT STRESS (PSI)=" +SE);
ELSE
MSGBOX ("THIN WALL");
END;
END;


CALCULATING YIELD PRESSURE (API 5 C3).

EXPORT YIELDPRESS()
BEGIN
LOCAL OD, ID, YI, PY;
INPUT (OD, "OD (IN)=" );
INPUT (ID, "ID= (IN)=" );
INPUT (YI, "YIELD (PSI)=");
PY:=.875*(2*YI*(OD-ID)/2)/OD;
MSGBOX ("YIELD PRESSURE (PSI)=" +PY);
RETURN
END;

CALCULATING SHEAR AREA AND BEARING AREA ON ACME THREADS.

EXPORT THREAD()
BEGIN
LOCAL D, N, P, ES, KN, M, SA, BA;
INPUT (D, "OD=" );
INPUT (N,"NO OF THREAD PER INCH" );
P:=1/N;
ES:=D-.5*P-.008*D^.5-.006*D^.5-.03*(1/N)^.5;
KN:=D-P+.05*P;
M:=D-.05*P;
SA:=PI*KN*(.5+N*TAN(14.5)*(ES-KN));
BA:=(M^2-KN^2)/4*N*PI;
MSGBOX ("ACME 2G, SHEAR AREA=" +SA);
MSGBOX ("BEARING AREA=" +BA);

END;

CALCULATING GROSS MARGIN (IN %) WHEN COST AND PRICE ARE KNOWN.

EXPORT COST()
BEGIN
LOCAL P, C, GM;
INPUT (P, "PRICE=" );
INPUT (C, "COST=" );
GM:=100-(100*C/P);
MSGBOX ("GROSS MARGIN (%)=" +GM);

END;


CALCULATING PRICE WHEN COST AND GROSS MARGIN (IN %) ARE KNOWN.

EXPORT GROSSMARGIN()
BEGIN
LOCAL G, C, P;
INPUT (G, "GM (%)" );
INPUT (C, "COST=" );
P:=C/(1-G/100);
MSGBOX ("PRICE=" +P);
RETURN
END;

CALCULATING FUTURE VALUE WHEN PRESENT VALUE, INTEREST PER YEAR, AND PERIOD IN YEAR ARE KNOWN.

EXPORT FUTUREVAL ()
BEGIN
LOCAL PV, I, P, N, FV;
INPUT (PV, "PRESENT VALUE=" );
INPUT (I,"INTEREST (ANNUAL)=" );
INPUT (N, "PERIOD (IN YEAR)=");
FV:=PV*(1+I/100)^N;
MSGBOX ("FUTURE VALUE=" +FV);

END

Eddie


This blog entry is property of Edward Shore.  2015.