BBC BASIC
« Something to play with.....but not a game! »

Welcome Guest. Please Login or Register.
Jan 20th, 2018, 4:22pm


Cross-platform BBC BASIC (Win32, Linux x86, Android, Mac OS-X, Raspberry Pi)

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Something to play with.....but not a game!  (Read 318 times)
RNBW
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 23
xx Something to play with.....but not a game!
« Thread started on: Mar 30th, 2017, 5:36pm »

Any structural engineers out there who would like to pull this apart?

On Windows 10, it runs in BB4W and BBCSDL. I've not had chance to check BBCSDL on the Mac yet, but see no reason why it shouldn't run there also.
Code:
      REM **********************************
      REM  Filename: BMSFDEF_06.bbc
      REM **********************************

      INSTALL @lib$+"FNusing"

      DIM vs(11), ms(21), s(21), ds(21)

      INPUT "ENTER TITLE: ";  Title$

      PRINT "UNLESS THERE IS REASON TO DO OTHERWISE"
      PRINT "ENTER gk = 1 AND qk = 1"
      PRINT "THESE FIGURES WILL DEPEND ON THE CODE OF PRACTICE USED."
      INPUT "ENTER PARTIAL FACTOR OF SAFETY - DEAD LOAD, gk: "; gk
      INPUT "ENTER PARTIAL FACTOR OF SAFETY - IMPOSED LOAD, qk: "; qk

      PRINT "UNLESS OTHER DATA IS NEEDED, ENTER ELASTIC MODULUS = 25000"
      INPUT "ENTER ELASTIC MODULUS, E - N/sq.mm: ";  ec
      INPUT "ENTER SPAN OF BEAM, L - metres: "; L
      PRINT "ENTER BEAM SIZE (e.g. 400 x 600mm):"
      INPUT "ENTER BEAM BREADTH, b = "; bWidth
      INPUT "ENTER BEAM DEPTH, d = "; bDepth

      i2 = bWidth*bDepth^3/12
      PRINT "Iz = ";
      PRINT FNusing("##.####", i2/10^12);
      PRINT "*10^12mm^4"
      PRINT
      INPUT "ENTER NUMBER OF LOADS ON SPAN: "; nl

      DIM t1(nl), wc(nl), a(nl), c(nl), DorI$(nl), wd(nl)

      PRINT
      PRINT "LOAD TYPES:"
      PRINT "1..POINT LOAD"
      PRINT "2..UNIFORMLY DISTRIBUTED LOAD"
      PRINT "3..TRIANGULAR LOAD, SLOPING LEFT"
      PRINT "4..TRIANGULAR LOAD, SLOPING RIGHT"
      PRINT
      FOR j = 1 TO nl
        PRINT "LOAD NUMBER ";j
        INPUT "ENTER LOAD TYPE 1, 2, 3 OR 4: ";  t1(j)
        INPUT "ENTER LOAD'S CHARACTERISTIC WEIGHT, W - kN: ";  wc(j)
        INPUT "ENTER LOAD START DISTANCE FROM LEFT SUPPORT, A - metres: "; a(j)
        INPUT "ENTER LOAD COVER LENGTH (0 IF POINT LOAD), C - metres: "; c(j)
        INPUT "ENTER LOAD DEAD OR IMPOSED - D or I: "; DorI$(j)
  
        IF DorI$(j) = "D" OR DorI$(j) = "d" THEN wd(j) = wc(j) * gk
        IF DorI$(j) = "I" OR DorI$(j) = "i" THEN wd(j) = wc(j) * qk
      NEXT

      GOSUB (CalcSFBM)
      GOSUB (CalcDefl)

      CLS
      PRINT
      PRINT "TITLE: "; Title$
      PRINT
      PRINT "PARTIAL FACTORS OF SAFETY:"
      PRINT "PARTIAL FACTOR OF SAFETY FOR DEAD LOAD = ";gk
      PRINT "PARTIAL FACTOR OF SAFETY FOR IMPOSED LOAD = ";qk
      PRINT "ELASTIC MODULUS = "; ec; "N/sq.mm"
      PRINT "2nd MOMENT OF AREA = "; i2/10^12; " * 10^12 mm. units"
      PRINT "SPAN OF BEAM = ";L; "metres"
      PRINT "CHARACTERISTIC LOADS (kN) AND POSITION (metres)"
      PRINT "NUMBER OF LOADS ON SPAN = ";nl
      PRINT "TYPE        WEIGHT       DIST.A         DIST.C     D or I"
      PRINT "              kN         metres         metres"
      FOR j = 1 TO nl
        PRINT TAB(3); t1(j);
        PRINT TAB(14); FNusing("##.##", wc(j));
        PRINT TAB(26); FNusing("##.##", a(j));
        PRINT TAB(41); FNusing("##.##", c(j));
        PRINT TAB(54);DorI$(j)
      NEXT

      PRINT "PRESS ANY KEY TO CONTINUE..."
      GOSUB (pause)

      PRINT
      PRINT "RESULTS:"
      PRINT "--------"
      PRINT "LEFT REACTION = "; INT(ra*100)/100;"kN"
      PRINT "RIGHT REACTION = "; INT(rb*100)/100;"kN"
      PRINT "SHEARS AND MOMENTS AT 10th INTERVALS ALONG SPAN:"
      PRINT "SECTION  DIST(m)    SHEAR(kN)        moment(kN.M)      DEFLECTION(mm)"
      PRINT "---------------------------------------------------------------------"
      FOR k = 1 TO 21 STEP 2
        z = (k-1) *L/20
        PRINT TAB(3); k;
        PRINT TAB(10); z;
        PRINT TAB(18); FNusing("#####.##", vs((k+1)/2));
        PRINT TAB(35); FNusing("#####.##", ms(k));
        PRINT TAB(56); FNusing("####.##", ds(k))
      NEXT

      PRINT "MAXIMUM MOMENT = "; FNusing("####.##", mm);"kN.m ";
      PRINT "AT A DISTANCE X = "; FNusing("###.##", sm);"metres FROM LEFT SUPPORT"
      PRINT "MID-SPAN MOMENT = "; FNusing("####.##", ms(11));"kN.m"
      PRINT "MAXIMUM DEFLECTION = "; FNusing("###.##", dm);"mm ";
      PRINT "AT A DISTANCE X = "; FNusing("###.##", sd);"metres FROM LEFT SUPPORT"

      PRINT "PRESS ANY KEY TO END PROGRAM"
      GOSUB (pause)
      PRINT "PROGRAM ENDED"

      END

      REM *************************************************
      REM             SUBROUTINES
      REM *************************************************

      (CalcSFBM)
      ra = 0: rb = 0: mm = 0: sm = 0
      FOR k = 1 TO 11
        vs(k) =0
      NEXT k

      FOR k = 1 TO 21
        ms(k) = 0
      NEXT k

      REM CALCULATE REACTIONS
      FOR j = 1 TO nl
        t1 = t1(j)
        w = wd(j)
        a = a(j)
        c = c(j)
  
        CASE t1 OF
          WHEN 1: s = a
          WHEN 2: s = a + c/2
          WHEN 3: s = a + 2 * c/3
          WHEN 4: s = a + c/3
        ENDCASE
  
        t = L - s
  
        rl = w * t/L: rr = w - rl
        ra = ra + rl: rb = rb + rr 
  
        REM CALCULATE SHEAR FORCES AT SECTIONS ALONG BEAM
        vs(1) = vs(1) + rl
        vs(11) = vs(11) - rr
  
        FOR k = 2 TO 10
          z = (k-1)*L/10
          z1 = z -a
          CASE t1 OF
            WHEN 1:
              IF z < a THEN
                vk = rl
              ELSEIF z > a + c THEN;
                vk = -rr
              ELSEIF z = a + c THEN;
                vk = 0
              ENDIF
            WHEN 2:
              IF z < a THEN
                vk = rl
              ELSEIF z > a + c THEN;
                vk = -rr
              ELSE
                w1 = w * z1/c: vk = rl - w1
              ENDIF
            WHEN 3:
              IF z < a THEN
                vk = rl
              ELSEIF z > a + c THEN;
                vk = -rr
              ELSE
                w1 = w * (z1/c)^2: vk = rl - w1
              ENDIF
            WHEN 4:
              IF z < a THEN
                vk = rl
              ELSEIF z > a + c THEN;
                vk = -rr
              ELSE
                z2 = c - z1: w1 = w * (z2/c)^2: vk = w1 - rr
              ENDIF
          ENDCASE
    
          vs(k) = vs(k) + vk
        NEXT k

        REM CALCULATE BENDING MOMENTS AT SECTIONS ALONG BEAM  
        FOR k = 2 TO 21
          z =(k-1)*L/20
          z1 = z - a
          CASE t1 OF
            WHEN 1:
              IF z <= a THEN
                mk = rl * z
              ELSEIF z >= a + c THEN
                  mk = rr * (L - z)
                ENDIF
              ENDIF
            WHEN 2:
              IF z <= a THEN
                mk = rl * z
              ELSE IF z >= a + c THEN
                  mk = rr * (L - z)
                ELSE
                  w1 = w * z1/c: mk = rl * (a + z1) - (w1 * z1/2)
                ENDIF
              ENDIF
            WHEN 3:
              IF z <= a THEN
                mk = rl * z
              ELSE IF z >= a + c THEN
                  mk = rr * (L - z)
                ELSE
                  w1 = w * (z1/c)^2: mk = rl * (a + z1) - (w1 * z1/3)
                ENDIF
              ENDIF
            WHEN 4:
              IF z <= a THEN
                mk = rl * z
              ELSE IF z >= a + c THEN
                  mk = rr * (L - z)
                ELSE
                  z2 = c - z1: w1 = w * (z2/c)^2: mk = rr * (L - a - c + z2) - (w1 * z2/3)
                ENDIF
              ENDIF
          ENDCASE
    
          ms(k) = ms(k) + mk
        NEXT k
      NEXT j

      FOR k = 1 TO 21
        IF ms(k) > mm THEN mm = ms(k): sm = L * (k - 1)/20
      NEXT

      RETURN

      REM CALCULATE DEFLECTIONS
      (CalcDefl)
      dm = 0: sd = 0
      REM  SET UP SIMPSON'S ORDINATES
      s(1) = 0: s(21) = 0
      FOR k = 2 TO 20
        IF k/2 = INT(k/2) THEN s(k) = 4
        IF k/2 > INT(k/2) THEN s(k) = 2
      NEXT

      REM  NUMERICAL INTEGRATION
      FOR k = 1 TO 21
        dk = 0
        zd = (k - 1) * L/20
        FOR k1 = 1 TO 21
          REM  UNIT LOAD MOMENTS
          z = (k1 - 1) * L/20
          IF z <= zd THEN mx = z * (L - zd)/L
          IF z > zd THEN mx = zd * (L - z)/L
          REM  SUMMING MOMENT PRODUCTS AND SIMPSON'S ORDINATES
          dk = dk + ms(k1) * mx * s(k1)
        NEXT k1
        ds(k) = dk * L * 10^12/20/3/i2/ec
      NEXT k

      FOR k = 1 TO 21
        IF ds(k) > dm THEN dm = ds(k): sd = L * (k - 1)/20
      NEXT k

      RETURN

      (pause)
      INPUT n$
      RETURN
 


Unfortunately, to get everything to fit, I've had to leave out some of the comments and a list of variables. If anyone would like a fully commented version this can be provided.

The program is based on code in R. Hulse and W.H. Mosley's excellent book "Reinforced Concrete Design by Computer". Very good book, but unfortunately now a bit long in the tooth. I'm sure if the book was updated, the programs would be written in a language other than BASIC, regretfully.

The program can be developed to design steel, timber and concrete beams to various codes of practice. Unfortunately, the last time I did any structural design was in 1985 and British Codes have moved on quite a way since then with Eurocodes. But if anyone would like to take up the challenge!!!!

User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 689
xx Re: Something to play with.....but not a game!
« Reply #1 on: Mar 31st, 2017, 1:57pm »

on Mar 30th, 2017, 5:36pm, RNBW wrote:
Any structural engineers out there who would like to pull this apart?

Not me, that's for sure. I have quite a broad spectrum of interests, but structural engineering isn't one of them!

If you want suggestions for the code, how about providing a GUI method of entering the data? The usefulness of the program would be greatly improved if one could immediately see the effect of changing just one parameter and leaving the others unchanged.

So I would suggest a dialogue box with entry fields for each of the parameters and an OK button to run the calculations.

And shouldn't there be a graphical representation of the beam with an indication of where the loads are applied and the resulting deflections (probably exaggerated)? Perhaps even a simulated isochromatic stress pattern would be nice.

Richard.

Here's an example from one of my programs of a not dissimilar entry form:

User Image
« Last Edit: Mar 31st, 2017, 2:04pm by Richard Russell » User IP Logged

RNBW
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 23
xx Re: Something to play with.....but not a game!
« Reply #2 on: Apr 1st, 2017, 11:44am »

Hi Richard

Thanks for your response. I've not received a response from anyone else, so it doesn't look as if there are many structural engineers out there using BBC Basic.

You may not remember, some months ago on the LBB forum, you gave me some very useful advice on the production of a grid of textboxes. This was to produce a GUI for a simple beam program. Unfortunately, I got waylaid and never got back to finishing it.

I did produce a small grid for BBCSDL, so there is no reason why I shouldn't be able to expand on that. If I can find time between holidays, gardening and other things, I will probably give it a go. However, the code will be much longer than I have submitted here. What would you suggest as the best way to send the code?

By the way, on the subject of diagrams: what I used to do when I was submitting calculations for local authority approval was this:

Although the calculations were computer generated, they were printed out as if they had been produced by hand (this meant that the computer program did not need to be submitted for prior approval to the local authority). I left a space in the printout for a loading diagram and produced a simple hand-drawn sketch. Although they look pretty, with a simply supported single span beam, shear force, bending moment and deflection diagrams don't serve a very useful purpose. All the factual data is produced in the print-out. I might look at this with a GUI solution. I'll see.

Anyway, thank you for your response and for the dialog box presentation.

Best regards

Ray

User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 689
xx Re: Something to play with.....but not a game!
« Reply #3 on: Apr 1st, 2017, 3:42pm »

on Apr 1st, 2017, 11:44am, RNBW wrote:
I've not received a response from anyone else

Where else have you posted the message? There are very few users on this forum (Conforums) so to increase the likelihood of receiving a response you need to post to (at least) Groups.IO and the BB4W forum as well.

Quote:
What would you suggest as the best way to send the code?

Upload it to any public repository (e.g. a cloud storage service, or pastebin, or your own web space etc.) and then just include a link in your message.

Richard.
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

Donate $6.99 for 50,000 Ad-Free Pageviews!


This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls