ccaprani / pycba

Python Continuous Beam Analysis
https://ccaprani.github.io/pycba/
Apache License 2.0
61 stars 26 forks source link

Sum of envelopes #92

Open RoccoRaimo opened 4 months ago

RoccoRaimo commented 4 months ago

Hi @ccaprani! I was playing around with the library, in particular with the envelopes results obtained from a static and a moving vehicle analysis. I would like to suggest a new class method for envelopes class that permits the sum of multiple envelopes - instead of a single envelope of envelopes with augment. It would be very useful in some circumstances, i.e. when traffic load is applied with both distributed and concentrated loads or when a superposition of multiple vehicle is considered or - most likely - a superposition of traffic + snow distributed live loads is necessary.

Reading #6, #50 and #56, I think that the implementation could be very much similar to the augment method in envelopes class. Something like:

    if self.npts != env.npts or self.nsup != env.nsup:
        raise ValueError("Cannot sum with an inconsistent envelope")
    self.Vmax = np.add(self.Vmax, env.Vmax)
    self.Vmin = np.add(self.Vmin, env.Vmin)

    self.Mmax = np.add(self.Mmax, env.Mmax)
    self.Mmin = np.add(self.Mmin, env.Mmin)

    self.Rmaxval = np.add(self.Rmaxval, env.Rmaxval)
    self.Rminval = np.add(self.Rminval, env.Rminval)

    if self.nres == env.nres:
        self.Rmax = np.add(self.Rmax, env.Rmax)
        self.Rmin = np.add(self.Rmin, env.Rmin)
    else:
        # Ensure no misleading results returned
        self.Rmax = np.zeros((self.nsup, self.nres))
        self.Rmin = np.zeros((self.nsup, self.nres))

Let me know if this is a good idea and I can just open a pull request with the modified code. Maybe I could also include a jupyter notebook with an example. Thank you!

ccaprani commented 4 months ago

This would be a great addition, especially if coupled with a really practical use case. Is it that we're summing a patterned UDL for dead load for example, with the envelope for a live load perhaps?

RoccoRaimo commented 4 months ago

Exactly! Or in another scenario, maybe a superposition of multiple vehicle runs and a patterned UDL.

I will open a PR as soon as I'll be able to submit an example workbook (I'll put it right after the existing augment example).