CPT_bas

Developer(s): Jean-Claude Touzin
Date: 1989
Type: Diskette
Platform(s): QL
Tags: Home

A French-language program that works out a building’s heat-loss coefficient and the yearly cost of heating it. It asks 22 questions in windows on the screen: degree-days, altitude, months of heating, number of occupants, the prices of electricity, natural gas, heating oil, coal and wood, the area and insulation of the walls, ceiling, doors, windows and foundation, the volume and the air changes per hour.

It then gives the loss coefficient for each part in Btu per degree-day, the total (also in watts per degree C), the yearly loss and the heat given off by the occupants in MBtu, and the cost with each fuel, on the screen or the printer (ser). Menu choice 5 loads a sample house from the DATA (24 x 40 ft, 1988 prices). RUN starts it; the screens, prompts and REMarks are in French.

Published in QL_DOC April-May 1989 (CPT_bas).

Related Articles

CPT_BAS, a SuperBASIC program by Jean-Claude Touzin that calculates the coefficient of heat loss (CPT) of a house from walls, ceiling, doors, windows, foundation and air infiltration, and estimates yearly heating costs by electricity, natural gas, oil, coal and wood. The author explains the importance of accurate input, suggests testing it against an existing house's bills, and notes that sample data can be loaded from DATA lines (option 5 then 3), that it uses a function version of the offset routine, and that it was written on a JS ROM. The roughly 300-line listing follows.

Source Code

100 REMark J.C.Touzin, C.P.41, La Sarre, Qc  J9Z 2X4.
110 REMark coëfficient de perte thermique
120 DEFine PROCedure calcul
130 correct=(-3.2E-5*alti)+1
140 isol_fen=1/u_fen
150 cpt(1)=24*surf_m/isol_m
160 cpt(2)=24*surf_plaf/isol_plaf
170 cpt(3)=24*surf_porte/isol_porte
180 cpt(4)=24*surf_fen/isol_fen
190 SELect ON r_18
200 =1: fact_1=256: fact_2=8
210 =2: fact_1=100: fact_2=5
220 =3: fact_1=24: fact_2=0
230 END SELect
240 cpt(5)=fact_1*surf_fond/(isol_fond+fact_2)
250 cpt(6)=.432*correct*vol*change
260 cpt_total=cpt(1)+cpt(2)+cpt(3)+cpt(4)+cpt(5)+cpt(6)
270 ua=(cpt_total*2.197E-2)
280 perte_btu=(cpt_total*d_j/1E6)
290 jour_mois=30: btu_pers=20000
300 gain_therm_intrin=(btu_pers*pers*mois_c*jour_mois)
310 perte_gain=(perte_btu*1E6)-gain_therm_intrin
320 kilow=perte_gain/3413
330 gasmpc=(perte_gain/1E6)*1.45
340 huilegal=(perte_gain/180000)*1.5
350 charbonton=(perte_gain/2.51552E7)*1.55
360 boiscord=(perte_gain/2.19E7)*1.55
370  END DEFine calcul
380 DEFine  PROCedure resultat
390 PRINT#canal,\"====> RESULTATS: " & ref$
400 PRINT#canal, "====Coëfficients de perte thermique de l'édifice en Btu/degré-jour:"
410 FOR k= 1 TO 6
420 PRINT#canal, ! sect$(k) & offset$ (cpt(k),6,0," ") & "       " !
430 END FOR k
440 PRINT#canal,\"====Coëfficient de perte thermique totale en Btu/degré-jour= ";
445 PRINT#canal,offset$(cpt_total,6,0," ")
450 PRINT#canal,TO 50; "ou... ";offset$ (ua,6,0," ");" watts/°C (UA)"
460 PRINT#canal,"====Perte thermique totale pour l'année en MBtu= ";
465 PRINT#canal,offset$ (perte_btu,6,0," ")
470 PRINT#canal,,"Gain thermique intrinsèque en MBtu= ";
475 PRINT#canal,offset$ ((gain_therm_intrin/1E6),6,0," ")
480 PRINT#canal,,"Perte nette totale en MBtu= ";
485 PRINT#canal,offset$ ((perte_gain/1E6),6,0," ")
490 PRINT#canal,  "==== Coût approximatif du chauffage ";ref_ce$;":"
500 PRINT#canal,TO 15; "Electricité: ";offset$ (kilow,8,1," ");
505 PRINT#canal," kwh =";offset$ (kilow*kwh, 6,2,"$")
510 PRINT#canal,TO 15; "Gas naturel: ";offset$ (gasmpc,6,1," ");
515 PRINT#canal," million pi.cu. =";offset$ (gasmpc*mpc,6,2,"$")
520 PRINT#canal,TO 15; "Huile à chauffage: ";offset$ (huilegal,6,1," ");
525 PRINT#canal," gal.imp. =";offset$ (huilegal*gi,6,2,"$")
530 PRINT#canal,TO 15; "Charbon: ";offset$ (charbonton,4,1," ");
535 PRINT#canal," tonnes =";offset$ (charbonton*ton,6,2,"$")
540 PRINT#canal,TO 15; "Bois: ";offset$ (boiscord,4,1," ");
545 PRINT#canal," cordes (4 pi.) =";offset$ (boiscord*cord,6,2,"$")
550 END DEFine resultat
560 DEFine PROCedure affectation_2
570 d_j=r$(1): alti=r$(2): mois_c=r$(3): pers=r$(4)
580 kwh=r$(5): mpc=r$(6): gi=r$(7): ton=r$(8): cord=r$(9)
590 surf_m=r$(10): isol_m=r$(11)
600 surf_plaf=r$(12): isol_plaf=r$(13)
610 surf_porte=r$(14): isol_porte=r$(15)
620 surf_fen=r$(16): u_fen=r$(17)
630 r_18=r$(18)
640 surf_fond=r$(19): isol_fond=r$(20)
650 vol=r$(21): change=r$(22)
660 END DEFine affectation_2
670 DEFine PROCedure reponse_1
680 FOR r_b=1 TO 18, 21 TO 22
690 IF r_b=18: fondation: NEXT r_b
700 si_rendu_a=r_b
710 SELect ON si_rendu_a
720  =16: PRINT#0, message_16$
730  =17: PRINT#0, message_17$
740  =22: PRINT#0, message_22$
750 END SELect
760 reponse_2
770 END FOR r_b
780 END DEFine reponse_1
790 DEFine PROCedure reponse_2
800 INPUT#0, "Réponse à la question no." & r_b & ":";r$(r_b)
810 PRINT#(r_b+10), r$(r_b)
820 END DEFine reponse_2
830 DEFine PROCedure fondation
840 PRINT#0,message_18$
850 INPUT#0, "Réponse à la question no.18:";r$(18)
860 r_18=r$(18): quelle_fondation
870 CLS#28: CLS#29: CLS#30
880 PRINT#28, q$(18); r$(18)
890 PRINT#29, q$(19);
900 PRINT#30, q$(20);
910 INPUT#0, "Réponse à la question no.19:";r$(19)
920 PRINT#29, r$(19)
930 INPUT#0, "Réponse à la question no.20:";r$(20)
940 PRINT#30, r$(20)
950 END DEFine fondation
960 DIM sect$(6,14),q$(22,35),r$(22,10)
970 DIM cpt(6): RESTORE 2430: READ ref$,ref_ce$
980 affectation: menu: STOP
990 DEFine PROCedure menu
1000 ouvre_c: intro
1010 REPeat menu_b
1020 CLS#0
1030 PRINT#0, "1-Entrée des données   2-Correction des données"
1040 PRINT#0, "3-Résultats à l'écran 4-Résultats sur imprimante 5-" & ref$
1050 INPUT#0, "Taper 1, 2, 3, 4, 5 (ou 6 pour sortir du programme) ";v_n
1060 CLS#0
1070 SELect ON v_n
1080 =1: identification: CLS: place_f: ecran: reponse_1: affectation_2: calcul
1090 =2: identification:CLS :place_f: ecran: ajoute_r: corrige_quoi: affectation_2: calcul
1100 =3: CLS: canal=1: resultat
1110 =4: canal=3: imprimante
1120 =5: CLS: lecture: place_f: ecran: ajoute_r: affectation_2: calcul
1130 =6: EXIT menu_b
1140 END SELect
1150 END REPeat menu_b
1160 ferme_c
1170 END DEFine menu
1180 DEFine PROCedure intro
1190 WINDOW 512,256,0,0:PAPER 5:CLS:INK 7
1200     fenetre 1,504,202,2,2,2
1210     fenetre 0,504,42,2,209,4
1220 END DEFine intro
1230 DEFine PROCedure fenetre (canal,x,y,ox,oy,couleur)
1240 WINDOW#canal,x,y,ox+4,oy+4
1250 PAPER#canal,0:CLS#canal
1260 WINDOW#canal,x,y,ox,oy
1270 PAPER#canal,couleur
1280 CLS#canal
1290 INK#canal,7*(couleur<4)
1300 BORDER#canal,1,0
1310 END DEFine fenetre
1320 DEFine PROCedure ecran
1330 AT 0,0: PRINT entete$;" ";ref$
1340 oy=64
1350 FOR s_b=1 TO 6
1360 CURSOR 4,oy
1370 PRINT sect$(s_b)
1380 IF s_b=5: oy=oy+31: ELSE : oy=oy+20
1390 END FOR s_b
1400 FOR q_b=11 TO 32
1410 PRINT#q_b, q$(q_b-10);
1420 END FOR q_b
1430 END DEFine ecran
1440 DEFine PROCedure ouvre_c
1450 FOR oc=11 TO 32
1460 OPEN#oc,scr
1470 END FOR oc
1480 END DEFine
1490 DEFine PROCedure place_f
1500 px=8:py=13
1510 FOR pf=11 TO 32
1520 WINDOW#pf,240,10,px,py:PAPER#pf,4:CLS#pf:INK#pf,0
1530 px=px+252
1540 IF px>260:px=8:py=py+11
1550 test=pf
1560 SELect ON test
1570 =19,30: px=8:py=py+20
1580 =21,23,25,27: py=py+9
1590 END SELect
1600 END FOR pf
1610 END DEFine place_f
1620 DEFine PROCedure ferme_c
1630 FOR fc=11 TO 32
1640 CLOSE#fc
1650 END FOR fc
1660 END DEFine
1670 DEFine PROCedure corrige_quoi
1680 REPeat question_b
1690 INPUT#0, "No de l'item à corriger ou f pour fin: ";item_c$
1700 IF item_c$=="f":EXIT question_b
1710 item_c=item_c$: IF item_c=18: fondation: NEXT question_b
1720 SELect ON item_c
1730  =16: PRINT#0, message_16$
1740  =17: PRINT#0, message_17$
1750  =22: PRINT#0, message_22$
1760 END SELect
1770 INPUT#0, "Réponse à la question no." & item_c &":";r$(item_c)
1780 CLS#(item_c+10)
1790 PRINT#(item_c+10), q$(item_c); r$(item_c)
1800 END REPeat question_b
1810 END DEFine corrige_quoi
1820 DEFine PROCedure affectation
1830 entete$="CALCUL DU COEFFICIENT DE PERTE THERMIQUE D'UN EDIFICE."
1840 message_16$="Excepté les fenêtres du côté sud."
1850 message_17$="1 vitre=1, 2 vitres=.55, 3 vitres=.37" : REMark 1.1/1,  1.1/2,  1.1/3
1860 message_18$="Sous-sol=1,  plancher sur sol=2,  plancher sur espace d'air=3."
1870 message_22$="Très hermétique=.62, herm.=.93, moyen=1.23, peu herm.=1.54, très peu herm.=1.85"
1880 sect$(1)="Murs: "
1890 sect$(2)="Plafond: "
1900 sect$(3)="Portes: "
1910 sect$(4)="Fenêtres: "
1920 sect$(5)="Fondations: "
1930 sect$(6)="Infiltration: "
1940 q$(1)="1)Degrés-jours/année/°F:"
1950 q$(2)="2)Altitude en pieds:"
1960 q$(3)="3)Saison de chauffage(mois):"
1970 q$(4)="4)Nombre de résidents:"
1980 q$(5)="5)Electricité, coût/kwh:$"
1990 q$(6)="6)Gas naturel,coût/million pi.cu.:$"
2000 q$(7)="7)Huile, coût/gal.imp.:$"
2010 q$(8)="8)Charbon, coût/tonne:$"
2020 q$(9)="9)Bois, coût/corde 4 pieds:$"
2030 s_pc$="Surface, pi.ca.:"
2040 i_r$="Isolation,R:"
2050 q$(10)="10)" & s_pc$
2060 q$(11)="11)" & i_r$
2070 q$(12)="12)" & s_pc$
2080 q$(13)="13)" & i_r$
2090 q$(14)="14)" & s_pc$
2100 q$(15)="15)" & i_r$
2110 q$(16)="16)" & s_pc$
2120 q$(17)="17)Facteur U:"
2130 q$(18)="18)1=ss 2=slab 3=plancher esp.air:"
2140 q$(19)="19)Longueur des murs en pieds:"
2150 q$(20)="20)" & i_r$
2160 q$(21)="21)Volume en pi.cu.:"
2170 q$(22)="22)Changement air/heure:"
2180 END DEFine affectation
2190 DEFine PROCedure ajoute_r
2200 FOR ajoute_b= 1 TO 22
2210 PRINT#(ajoute_b+10), r$(ajoute_b)
2220 END FOR ajoute_b
2230 END DEFine ajoute_r
2240 DEFine PROCedure imprimante
2250 OPEN#3,ser
2260 PRINT#3, entete$ "----> ";ref$
2270 FOR imp_b=1 TO 22
2280 SELect ON imp_b
2290 =10: PRINT#3, "====" & sect$(1)
2300 =12: PRINT#3, "====" & sect$(2)
2310 =14: PRINT#3, "====" & sect$(3)
2320 =16: PRINT#3, "====" & sect$(4)
2330 =18: PRINT#3, "====" & sect$(5)
2340 =21: PRINT#3, "====" & sect$(6)
2350 END SELect
2360 PRINT#3, !q$(imp_b) & r$(imp_b)!
2370 END FOR imp_b
2380 resultat
2390 CLOSE#3
2400 END DEFine imprimante
2410 DEFine PROCedure lecture
2420 REMark données pour entrée automatique par le programme
2430 DATA "24x40, R s-s=8,R r-c=28.05", " ($ 1988) ": REMark année de référence
2440 DATA 11537, 1000, 8, 4
2450 DATA ".04", "0.00", "1.34","0.00" , "60.00"
2460 DATA 754, 28.05, 960, 35
2470 DATA 42,10, 90, .37
2480 DATA 1, 128, 8
2490 DATA 15360, .62
2500 RESTORE 2430
2510 READ ref$, ref_ce$
2520 FOR l_b=1 TO 22
2530 READ r$(l_b)
2540 END FOR l_b
2550   r_18= r$(18)
2560 quelle_fondation
2570 END DEFine lecture
2580 DEFine PROCedure quelle_fondation
2590 SELect ON r_18
2600 =1: q$(19)="19)Longueur des murs en pieds:"
2610 =2: q$(19)="19)Périmètre en pieds:"
2620 =3: q$(19)="19)Surface du plancher en pi.ca.:"
2630 END SELect
2640 END DEFine quelle_fondation
2650 DEFine PROCedure identification
2660 edi$="Nom de l'édifice (25 caract. max.)? "
2670 cout$="Année de référence pour les coûts de l'énergie"
2680 REPeat ident_b
2690 CLS
2700 PRINT,,,\"1)"  & ref$\,,,,,"2)" & ref_ce$
2710 INPUT\,,,"Taper 1, 2 ou f pour fin",reponse$
2720 IF reponse$=="f": EXIT ident_b
2730 reponse=reponse$
2740 SELect ON reponse
2750 =1: INPUT\,(edi$),ref$
2760 =2: INPUT\,(cout$),ref_ce$: ref_ce$="$ " & ref_ce$
2770 END SELect
2780 END REPeat ident_b
2790 END DEFine identification
2800 DEFine FuNction offset$ ( var, entier, dec, signe$)
2810 LOCal arrondi,place_point,var$,debut,fin
2820 arrondi=10^-dec * INT((var+5 * 10^-(dec+1)) * 10^dec)
2830 arrondi$=arrondi
2840 IF ("E" INSTR arrondi$)<>0: not_scient arrondi$
2850 var$=(FILL$(" ",9)) & signe$  & arrondi$ & (FILL$("0",10))
2860 place_point=("." INSTR var$)
2870 IF place_point <> 0
2880 debut=place_point-entier
2890 ELSE
2900 var$(LEN(var$)-9)="."
2910 debut=LEN(var$)-9-entier
2920 END IF
2930 IF dec=0: fin=debut+entier-1: ELSE fin=debut+dec+entier
2940 IF var$(debut-1) INSTR "-123456789" <>0: var$=arrondi$: ELSE var$=var$(debut TO fin)
2950 RETurn var$
2960 END DEFine offset$
2970 DEFine PROCedure not_scient (arrondi$)
2980 place_E=("E" INSTR arrondi$)
2990 moins=("-" INSTR arrondi$ (1))
3000 moins_E=("-" INSTR arrondi$ (2 TO))
3010 ou_point=("." INSTR arrondi$)
3020  IF moins_E=0: million arrondi$: RETurn
3030 IF moins_E<>0: nbre_dec=arrondi$(moins_E+2 TO): ELSE nbre_dec=arrondi$(place_E+1 TO)
3040   arrondi$=arrondi$(1 TO place_E-1)
3050 IF ou_point<>0: arrondi_2$= arrondi$ (1 TO ou_point-1) & arrondi$ (ou_point+1 TO  ): ELSE arrondi_2$=arrondi$
3060 rempli$=FILL$("0", nbre_dec-1)
3070 IF moins<>0: arrondi$="-." & rempli$ & arrondi_2$(2 TO): ELSE arrondi$="." & rempli$ & arrondi_2$
3080 END DEFine not_scient
3090 DEFine PROCedure million (arrondi$)
3100 vers_droite=arrondi$(place_E+1 TO)
3110 arrondi$=arrondi$(1 TO place_E -1)
3120 IF ou_point=0
3130  rempli$=FILL$("0",vers_droite)
3140 arrondi$=arrondi$ & rempli$
3150 END IF
3160 IF ou_point<>0
3170 rempli$=arrondi$(ou_point +1 TO place_E -1)
3180 long=LEN(rempli$)
3190 IF long< vers_droite: rempli$=rempli$ & FILL$("0", vers_droite-long)
3200 arrondi$=arrondi$(1 TO ou_point-1) & rempli$
3210 END IF
3220 END DEFine million

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.