Welcome to lecture series in the course advanced geotechnical engineering, we are actually discussing module 3 on compressibility and consolidation and in the lecture 1 we introduced ourselves to stresses due to surface loads, so in this lecture 2 we will continue further in this particular topic that is in module 3 lecture 2 we are going to concentrate on stresses in soil from the surface loads. And we have discussed that when the soil can be subjected to different shapes, the loading can be of different shapes, it can be angular shape or it can be a circular shape or it can be a rectangular area or it can be an area of irregular shape or it can be of like in the loading intensity can vary from 0 to Q and remain a constant like embankment construction or levee construction or dam construction or in case of landfills we have certain you know very flat slopes and the heights can even range up to 200 meters or so. So it will be interesting you know to learn about this particular topic and to compute the stresses in soil from the surface loads. So we have actually introduced in the previous lecture that Bosnian theory and Westergaard's theory and from the Bosnian theory the number of you know the deductions can be made and here we actually have tried to discuss about in the previous lecture about the vertical stress due to the strip load that means that if you are having a strip foundation and if it is connected with let us say if a wall which is actually has a continuous foundation running over length L then the strip load is the load transmitted by the structure of the finite width and infinitely length infinitely long soil length along the soil surface. So the sigma ZB can be calculated by treating the strip loads as the line loads by treating strip loads as the line loads. So sigma Z is equal to P0 by pi theta plus sin 2 theta by 2 within theta 1 to theta 2. So theta 1 and theta 2 are nothing but theta 2 minus theta 1 is equal to theta where they are depending upon the location of the point of interest of this particular stress that is from the left side edge of let us say that if you are having a strip load and if it is at a certain distance from this point and certain distance from this point and the angle subtended from with the vertical and with the horizontal here is theta 1 and then with this vertical and then this point is theta 2. So theta 2 minus theta 1 that is the angle is actually over the breadth of the foundation. So we actually have said that sigma Z the P0 is nothing but Qs, Qs by Q pi and theta plus sin 2 theta by 2 this is what actually we have discussed in the previous lecture. And the contours of the equal vertical stress of uniformly load intensity which are actually given here and the pressure bulbs it can be seen here under the strip area the depth of influence can actually go up to 3B and in case of square area the depth is limited. So the zone lying inside the vertical stress contour of value 0.2Q is described as the so within this zone and this is called as the pressure bulb the spread of the pressure bulb for the strip area is large compared to the square area. So this is here for the a square area or a square foundation or a footing subjected to uniform load intensity in a strip footing or strip foundation subjected to a uniform intensity is actually shown here and the zone within this is actually called as the bulb of pressure or pressure bulb and here what this figure shows is that under the strip area the zone of influence the depth of influence will be large compared to the square area. Now let us consider a strip carrying uniformly vertical loading on an infinite strip on the surface of a semi-infinite mass that means that let us assume that we are having a certain strip of width 2A it can be capital B is equal to 2A and the loading intensity is 0 at one point and it is Q at this point that is X is equal to 0 so this is along the X axis and this is along the depth axis that is Z axis. Now at X is equal to 0 the load intensity is 0 Q is equal to 0 and X is equal to 2A the loading intensity is equal to Q so there is a linearly varying loading intensity so that is the increasing vertical loading on an infinite strip and then this perpendicular to the plane of this figure let us assume that the load is actually is spreading over infinite length and in order to calculate the vertical stress in the due to increase in loading the type of loading like this what we do is that let us assume that we wanted to calculate the stress at a particular point P and if this let P be the point below this soil surface that is this coordinates of this point are X and Z where this distance is X and this distance is vertical depth is Z. Now for an elementary strip let us consider a small strip here that is of the breadth is equal to some ds the small strip and let us assume that the load intensity per unit length can be calculated by this particular ordinate, vertical ordinate can be calculated by similar triangles as Q by 2A that means that here at X is equal to S let us assume that there is a small strip of elementary strip of ds is there and it is at a distance S so this are vertical ordinate divided by S and this from the similar triangles here and this triangle we can calculate this magnitude as Q by 2A into S and that is the load and then the load intensity at that particular point into ds will give the so called load per unit width that is called the what we do is that we treat it like a small line load. Now let us assume that this distance is S so when this is equal to S X then this will be equal to X minus S. Now approximating as a line load so this is approximated as a line load now so the line load of certain intensity running of the infinite length and with the intensity of this line load is nothing but Q by 2A S into ds so now what we need to do is that we need to substitute in the expression for the vertical stress sigma Z is equal to 2Q by pi into Z cube by X square plus Z square to the raise 2 in this for Q substitute Q by 2A S into ds so that what we do is that because of this small strip load we get what is the small d sigma Z then when we integrate for the entire length of the 0 to 2A what we get is that the increase in vertical stress due to the particular load intensity. So this further we can actually continue like sigma Z is equal to the integral of d sigma Z and with by substituting you know the 1 by 2A and 2Q by pi into when S limits are nothing but this S is ranging from 0 that is X is equal to 0 and X is equal to 2A that is S is equal to 0 to S is equal to 2A and Z cube into S ds by X minus S whole square plus Z square to the raise 2. Now here what we did is that we substituted for substituted Q by 2A into S into ds for Q and X minus S for X and Z is kept it as Z so by integrating and then simplifying what we get is that sigma Z is equal to Q by 2 pi into X by A alpha minus sin 2 alpha sin 2 delta. So this alpha and delta which are nothing but this inclination that is this delta and then this is lambda this is alpha and this is delta. So let us assume that we are actually have interesting have a point at the this particular point here let us say that in that case what will happen is that the delta will be equal to 0 when this load intensity when we are actually interested in calculating this stress at this particular point then the load intensity at this particular point you know then in that case this delta will be equal to 0. Now we are actually having a case where alpha that is covering the breadth of this so called strip of width dA and delta. Now this with delta is equal to 0 and sigma Z is equal to Q by 2 pi into X by A alpha where after once we get the based on the you know the different depth requirements and once we compute this alpha then alpha need to be expressed in the radiance. So with sigma Z is equal to Q by 2 pi into X by A alpha minus sin 2 delta and when delta is equal to 0 that is right below the you know where the load intensity is actually high and then we can actually calculate that the sigma Z as Q by 2 pi into X by A into alpha. Now let us consider further we by using the same concept let us see that how you know we are we can actually construct the you know the stresses below the embankment loading or let us assume that we are having certain area loading over certain area because once we you know we learn about the consolidation and in order to calculate the settlements you need to calculate what is the increase in stress due to loading let us say embankment loading or due to landfill loading or due to certain you know dam or levy loading. So in this case let us consider a simple embankment is you know simplified with having an horizontal distance A and horizontal distance of the slope portion is A and this is actually B. So this vertical the load intensity is simplified by you know having Q is the load intensity and as we go down here the load intensity falls here. So here what we can do is that we can actually use the same concept now at this point here this point is right lies right below the right below this point Q and alpha 2 is the synchronization and alpha 1 is the synchronization and now what we do is that we will use the method of superposition and what we do is that in order to compute the vertical stress at a semi infinite mass due to embankment loading what we need to do is simply extend this line further and calculate by using again similar triangles between this triangle and this particular triangle and this particular you know triangle. So what we get is that we can actually calculate this width is equivalent to B so from the similar triangles again we can actually get what is the load intensity that is nothing but Q into B by A. So this particular loading is assumed as a fixious loading and we converted this embankment loading into a triangular strip having load intensity varying from Q0 to Q into 1 plus B by A and A plus B is the total horizontal distance of the strip and the point is actually lies right below the that is at the center of the embankment. So this angle is nothing but the alpha 1 plus alpha 2 and this width is nothing but A plus B now because as this loading is not there so what we need to do is that this particular stress additional loading due to this fixious portion what we assume need to be deducted so that point the stress due to that one is say sigma z 1 and stress due to this portion is say sigma z 2 so sigma z at point A is equal to sigma z 1 minus sigma z 2 so here this particular triangle which is nothing but having intensity Q into B by A and breadth B so this triangle is having B and then this inclination because what this breadth B the angle is alpha 2 so this is the alpha 2 angle. So once we determine simplify further by using we have said that if the loading intensity if the load under the reference is actually right below the you know the wherever the load intensity is maximum the point below the soil surface then using sigma z is equal to Q by 2 pi into x by A alpha now what we do is that we substitute A plus B for x and A plus B by 2 for A alpha 1 plus alpha 2 for alpha. So for sigma z 1 that is the stress sigma z 1 that is the stress due to you know this particular point due to the entire this triangle so the load intensity is nothing but Q plus B by A into Q that is why we have written for Q we have written Q plus B by A into Q 2 pi into for x now we are writing because the breadth the strip width is nothing but A plus B so we are writing A plus B and then A plus B by 2 that is for A that is nothing but this portion now into alpha 1 plus alpha 2 so and similarly you know for sigma z 2 which is nothing but Q into B by A into 2 pi into B by B by 2 into alpha 2 so when we you know take the difference that sigma z is equal to sigma z 1 minus sigma z 2 is nothing but Q by pi Q is nothing but the magnitude of the embankment so how to get that is by if you know the embankment loading having let us say you know today if is embankment is constructed with a field material having a unit weight of 20 kilo Newton per meter cube then 20 into let us say embankment height is say 5 meters then it is about 120 kilo Pascal so 120 kilo Newton per meter square so 120 R Q by pi into A plus B by A into alpha 1 plus alpha 2 minus B by A into alpha 2. Now so this is indicated as sigma z is equal to I influence factor that is the IE that is IE is nothing but the influence factor for embankment loading where IE is nothing but this entire multiplication that is this 1 by pi into A plus B by A into alpha 1 plus alpha 2 minus B by A into alpha 2 which is actually nothing but you know the function of 1 by pi into function of A by z into B by z where A by z is nothing but that the distance A or that horizontal portion of the embankment and the distance B which is horizontal portion of the slope of the embankment slope portion of the embankment and the horizontal portion of the from the crest of the embankment to the center line of the embankment where we can write that A by z and B by z so sigma z is equal to IE into Q so this for this actually the Osterberg charts are available and where we can actually use this Osterberg charts and then try to get the stress values say for example here the IE embankment that is IE influence factors are given and here the values of A by z ranging from 0.01 to 10 are given here and this can be used for even for embankment with B is equal to 0 that means that if you are having only triangular strip loading then the entire B by z is equal to 0 so then this curve we have to use and then we actually have depending upon the A by z value we can actually calculate the influence factor sigma z into this influence factor into the load intensity sigma z is equal to IE into Q we will be able to get what is the increase in vertical stress due to you know the embankment loading. So what we need to notice that this point will give the embankment stress at this point or in this case if you are talking about you know the stress suppose B is equal to 0 then that means that the stress actually occurs only at the center point. Let us say that we are having you know the loading which is symmetrical about you know let us say about the x axis where you know at the center it is actually having a load intensity Q and then on the both the sides actually is reducing to 0. So in this case what we need to do is that we need to calculate the influence factor and multiply with 2 so that you know we get the load intensity due to this and then load intensity due to this one. For example here when we have this is the symmetry of the embankment and if you wanted to take the stress due to embankment of the remaining portion then this multiplied into 2 we will be able to get the stress due to the complete embankment that is the total embankment distance. So this Osterberg charts are actually used for calculating the vertical stresses for the embankment loadings where you know the theory which is actually is deduced from the triangular strip having you know linearly varying increasing load and from there what we have deduced is that we have deduced the sigma z is equal to sigma z1 minus sigma z2 and from there we have actually got the expression for IE as a function of A by z and A is nothing but the horizontal distance of the embankment in the slope portion and B is nothing but the horizontal distance of the embankment from the crest of the embankment to the center line of the embankment. So by using this the increase in vertical stress at different points can be calculated. Let us look into an example having you know example problem having a 5 meter high embankment basically it is to be constructed as shown in the figure and if the unit weight of the compacted soil is 18.5 kilo Newton per meter cube and calculate the vertical stress due to solely to the embankment loading. So there can be initial effective stresses but however what we are interested is that by treating this mass as weightless medium we calculate what is the increase in the vertical loading due to solely due to the embankment loading only at point A at point B and at point C. So if you notice that you know we do not have the symmetry here but is at the center but we need actually the embankment loading. So if you look into this portion at point A this portion of the embankment causes the loading and this portion of the embankment causes the loading. So if you call this portion of the embankment as portion A and portion B and the sigma z at A is equal to sigma z A1 and sigma z A2. If this is portion A this portion is called as A1 this portion called as A2 then the sigma z A is nothing but sigma z A1 and sigma z A2 so both need to be added. Now here when it comes to this point we are having an embankment of you know this particular shape so the stress due to this portion and stress due to this portion and stress this to this portion need to be deducted. So this portion this stress need to be deducted. Now when it comes to this point here we construct a fictitious embankment and then afterwards we again remove the loading due to the load due to the stress increase in stress due to this much portion. So with that what will happen is that we get the increase in stress at a point C away from the embankment also. So here what we need to do is that by using the same notations and by using the method of superposition we can actually calculate the vertical stresses at point A, point B and point C. The method is that we first have to you know see how the embankments can be divided and if any fictitious portion need to be added it can be added and then you know then again the stress due to that particular features portion need to be deducted. Once that is done we will actually able to get the stresses at point A, point B, you know point C and if required if you are having any point here at the toe that is like say B1 that also can be calculated. Now by let us say we have actually discussed about you know the linearly varying load and an embankment stresses due to embankment loading and for certain type of loading in the loading areas we can also have you know the circular areas carrying the uniform intensity that means that it can be a ring foundation or it can be a foundation for chimney with a raft of having 2R diameter let us say and in that case you have a ring a raft of having 2R diameter so that means it be subjected to or let us say that you we have say oil storage tank having you know diameter of about some 46 meters or so then if it is subjected to oil of certain unit weight or certain height and it is subjected to certain increase in stress. So in order to calculate the increase in stress due to you know any oil storage tank having certain diameter or with certain load intensity we can actually then in practical applications we may have this type of circular areas carrying uniform pressures. Sometimes we also can have a you know the ring foundations that means that if you are actually having R1 and R2 where R2 is greater than R1 so R2 minus R1 portion that much is the breadth of the ring and over which the loading is actually happens with uniform intensity Q. So using Bosnik's point load solution so this can be reduced for example in this particular slide and we are actually having a circular shape loaded area having at the center and we are actually calculating the increase in vertical stress at the center point of the below the center of the you know this so called circular area and subjected to uniform load intensity. If R is the radius that is 0 here and extending here now consider a you know a small sector where you know with an angle d alpha then you know this portion this length of the arc which is nothing but L into R into d alpha L is equal to R into d alpha and assume that the small strip is actually having you know this so called this distance radial distance is dr the strip width here is dr and it is at a distance smaller from the center.  Now due to that so called you know the small element load is subjected to increase in intensity q into dr into rd alpha we can calculate d sigma z is equal to 3q dr into rd alpha so is nothing but 3q by 2 pi into zq by r square plus z square to the raise pi by 2 this is what actually we have discussed for q capital q what we substituted is that the small dq is nothing but q into dr into rd alpha by 2 pi into zq by r square plus z square over the raise pi by 2. Now increase in vertical stress at a due to the entire loaded area so in order to get this what we need to do is that the entire area is 0 to 2 pi alpha is actually ranging from here alpha is equal to 0 here and then alpha is equal to 2 pi and the radius that is the this circle and then this this bit is actually given by r is equal to 0 to r so we need to do the double integration sigma z is equal to d sigma z is equal to integral of d sigma z is equal to integral of alpha is equal to 0 to alpha is equal to 2 pi integral of r is equal to 0 to r is equal to 2 pi and for the the small d sigma z we can substitute here where 3q by 2 pi into z cube into r so this particular r into r square plus z square to the raise pi by 2 into dr d alpha. So once we substitute and you know we integrate the do the double integration and substitute what we get is that sigma z is equal to q into within square bracket brackets 1 minus 1 by 1 plus r by z whole square to the raise 3 by 2. So this particular you know portion this particular component of this particular equation is calculated as influence factor for the circular loaded area. So for different r by z values so this this this particular increase in stress due to at the center of the loaded area. Suppose if you are actually wanted due to load due to the if you if the increase in stress due to this loaded area away from the center then we need to have we need to use some other influence factor values but this is actually valid for the increase in vertical stress due to the load subjected to uniform load intensity having q and that too at the center of the loaded area only. So sigma z is equal to q into 1 minus 1 by r 1 by r by z whole square to the raise 3 by 2 that is a q into i c where i c is nothing but the influence factor for the circle loaded area. So this we can actually get by using charts also. So here the circle area carrying uniform pressure so the chart which is actually given here in terms of 2 r by z where r d is equal to capital 2 r and i c that is the influence factor. So what we can get is that by knowing the d by z for a let us say that we have a d by z value of 1 and the influence factor is 0.3. So that means that 0.3 into q that is the increase in stress due to the particular circle load area and this vertical stress is at the center of the circular loaded area. So consider an example here where a rectangular concrete tower is provided on a raft on a ring foundation and mostly these chimney foundations particularly in the coal base of Dharma power stations in steel plants you will find these chimneys and they are resting on ring foundations and in this particular problem the inner diameter of the ring foundation is given as 6 meters and outer diameter is given as 12 meters that means that here the inner diameter so the breadth of this ring foundation is nothing but 12 minus 6 meters that is 6 meters and on this you know annually if you say that we are having a annual ring having you know the breadth of 6 meters. So on this area due to you know the loading the different sorts of loading due to the shelf of the shell of the you know this element then you know the subjected to a 150 kilo Pascal's of loading. So we need to calculate what is the vertical stress at the center at 6 meter depth below the foundation. So for this you know we have if you notice here the central portion is not subjected to any loading. So what we need to do is that you calculate the in order to get the sigma ZA you know calculate the vertical stress due to the entire area that is entire diameter that is 24 meters diameter and minus the stress instant intensity due to you know this particular portion because this is particular portion is not loaded only this portion is subjected to load then you know what we can get is that we will get that net increase in stress due to the loading on the ring foundation. So we need to use the same equation that is in case of R first we need to use here 12 meters then we get the sigma Z then afterwards we need to use the R is equal to 6 meters then we get the vertical stress that is 1 q into 1 minus 1 by 1 plus 12 by 6 whole square to the raise 3 by 2 minus q into 1 minus 1 by 6 by 6 whole square to the raise 3 by 2. So the net difference sigma z 1 minus sigma z 2 we get the so called the increase in vertical stress at a depth 6 meters below the so called reinforced concrete tower having a ring foundation which is subjected to load intensity of 150 kilo pastels. So after having you know looking to you know the so called you know the circled area and the embankment loadings let us also look into the vertical stresses below a rectangular loaded area where in this particular figure where we it can be seen that this is the x axis and this is y axis and this is the uniform vertical load q per unit area and we are having a rectangular loaded area L is the length along the x axis and B is the breadth along the y axis and this is the jet. So we are actually calculating at one of its corners of the rectangle so let us say that if you are having a rectangular area of 2L by 2B so that means that we actually have to multiply with the four times of that particular you know load intensity by this is nothing but the method of superposition. So again you know in order to calculate the increase in load intensity due to a rectangular loaded area. So here if you want to calculate let us say for square loaded area when L is equal to B so with that also you are able to get for the square loaded area. So here let us take for L and B and at one of the corners like you know this corner is under consideration now so we are actually calculating the this x is equal to 0 y is equal to 0 and the along the z axis that is you know the depth z. So you know we can actually calculate what is the increase in stress due to so again what we do is that we actually use the both sticks point load solution as we have done in the in the circular load. The stress at point P due to you know so the small increase in the stress vertical stress due to point point load acting on the small step which is actually is darkened portion here having dx along the x axis and dy along the y axis. So the area is dx into dy and the loading intensity is q per unit area. So q into dx dy is the small point load here acting at this particular point. So using d sigma z is equal to 3 q z q by 2 pi r to the power of 5 and with r square is equal to r square plus z square is equal to x square plus y square plus z square. So here what we can do is that 3 into for q what we do is that small q into dx dy. So small q into dx dy into z cube divided by 2 pi into for r what r for r what we are writing is that x square plus y square plus z square that is root over to the raise pi. So we get x square plus y square plus z square is equal to the raise pi by 2. So d sigma z is equal to we have got something like 3 q dx dy z cube by 2 pi x square plus y square plus z square to the raise pi by 2. So here by using this vertical stress below a rectangular loaded area on the surface. So for this total increase in vertical stress at point p due to the entire loaded area can be determined by integrating with the limits like x is equal to 0 to x is equal to l and y is equal to 0 to y is equal to b. If you integrate in these limits like with l and b then we actually get one of the at one of the corners what is the increase in stress due to the loaded area. So this is simplified with sigma z is equal to q into i sigma.     So for this we have the Fordham charts, vertical stress below the rectangular loaded area on the surface can be obtained by using Fordham charts. The values for i sigma is equal to i can be obtained by using this Fordham chart which is given by Fordham in 1948 and where m is equal to b by z and i and these are the different curves for n is equal to 0.1, n is equal to 0.2, 0.3, 0.4 like this up to 2. So here by knowing these values so we get the influence factor and let us assume that we are actually calculating for a square area having b then we need to take say b by 2 and b by 2 and then we get the you know at the center to get this stress at the center of an area which is having loaded b by 2, b by b dimensions then in that case you have to take for b by 2 and in that case m is equal to 1 and depending upon the depth you can actually get based on that what you can get the influence factor and that influence factor into 4 times you have to multiply to get the load intensity to get the sigma z. So vertical stress below rectangular area on the surface can be given by sigma z is equal to q into i sigma. So i sigma is obtained let us say that at z is equal to 2 meters and b is equal to 2 meters then m is equal to 1 and n is equal to let us say that 0.3. So we will actually get the influence factor i is equal to about 0.07. So 0.07 multiplied by q into you know the configuration whatever we consider we have to use that one. So this is the Fodum chart which is given by Fodum in 1948 and these are used for the in order to calculate the vertical stress below a rectangular load area and it is possible for so if you are actually calculating to calculate the settlements in a soil layer particularly at the mid depth of the soil layer due to a rectangular load area then we have to use this particularly in place you know we have to add the increase in vertical stress due to this to the initial effective stress so that we get sigma 0 dash plus delta sigma. This delta sigma is the thing but at that particular point in the center of the clay layer how much the loaded area imposes the vertical stress can be calculated. So this is used even in calculating vertical stresses and in settlement estimations at all. So this is another view of the Fodum chart and where in a similar way it is actually expressed where m and i r or i sigma and where you know this is for the different n values which is given. So this is again to get the vertical stress at the one of the corners. Now let us try to take one example where we are actually having a load of 1500 kilo Newton is required to be carried on a foundation having a 2 meter square at a shallow depth of in a shallow depth in a soil bus. And we need to determine the vertical stress at a point below 5 meter below the surface below the center of the foundation assuming that the load is uniformly distributed over the foundation and assuming that load acts as a point load at the center of the foundation.  And another assumption what we have so the prime of AC the load intensity is nothing but uniform pressure is nothing but 1500 kilo Newton divided by 2 square that is 1500 divided by 2 square that is 375 kilo Newton per meter square. And if you look the 375 kPa into area we get the 1500 kilo Newton the load. So first is that we are assuming as a load intensity the increase in load the intensity is 375 kilo Pascal's. And so by taking we need to calculate at a depth of point 5 meter below the center of the foundation that means that we are having a square 2 meter by 2 meter. So here what we have is that you know we have 1 meter by 1 meter 4 squares are there and then at each corner that is at each one of the corner let us say that left corner we are actually getting for the increase in vertical stress at a certain depth of 5 meters and after getting the influence factor from the curve then 4q into IR. So here the 4 is multiplied because of we are actually divided that area into 4 and 4 into 375 into 0.018 so these are about 27 kilo Pascal's. And now the second portion of the problem as asked is that assuming that the load acts as a point load at the center of the foundation. So assuming that when r by z is equal to 0 we know that IP that influence factor for the point load is 0.4775 and it also can be given as 0.478 and by for the sigma z is nothing but q by z square into IP. So 1500 divided by z is nothing but 5 meters so 1500 by 5 square into influence factor for the assumption of point load is 0.478. So if you look into this the increase in vertical stress due to the point load is actually comes to be point load assumption for the in the given problem comes to us 29 kilo Pascal's which is actually more than what we have assumed for the uniform pressure. So we need to note here the point load assumption should not be used if the depth to the point x depth to the you know if the depth to the this particular point x under the reference is less than the 3 times the larger dimensions. For example in this larger dimension of the foundation is say you know 2 meters 2 into 3 is 6 meters and 6 into the depth is say 5 meters so it is if it is less than you know the so called 3 times the larger dimensions then this particular point load assumption is not valid that means z 1 as 1 e to calculate the assuming as the uniform pressure. Now we have discussed about rectangular areas having square areas or sometimes we may have combination of the areas so vertical stress due to a regular shaped area. Suppose if you are having irregular shaped area loaded with uniform loading density so it can be a combination of circular area or it can be of any shape let us say that it can be of any shape so if we need to calculate the vertical stress of any irregular shaped area and for this the new mark 1942 has developed you know the influence charts basically to compute the vertical stress and these influence charts are also there for horizontal and the shear stresses also within the soil mass due to the load area of any shape and irregular shape or it can be any shape in the sense it can be square area or it can be rectangular area and the point of interest if it is known then we can actually you know place the area drawn to the scale as per the procedure outline when you mark then you know we can calculate the at below any point on either side or outside the so here if you notice here we can calculate the vertical stress either the point can lie inside or outside as a whole we did not require to divide into you know the method of superposition will not be used. So here we can actually calculate and point on either side or outside the load area so for this you know the basis of this you know deducing this new mark chart is the circular loaded area subjected to uniform loaded density so we actually have deduced an expression for increase in vertical stores at the center of the circle for a circular loaded area okay. So based on this you know particularly by using this concept the new mark developed these influence charts now let us see that how this actually you know conceptualize and how this can be used in calculating the vertical stresses due to area of any shape irregular shape or any regular shape where for the point lying either inside or outside the loaded area. Now consider a circular low area of R1 loaded with a uniform load intensity q so that means that you are having a circular loaded area of having dimension R1 and O at the center and to be divided that is arbitrarily it has been divided into 20 sectors so like this OBC like that it is been divided into 20 sectors that means that each the center angle is about 18 degrees and then BC is that arc length like that this entire area is divided into 20 sectors. So this entire area is loaded to with a load intensity of q now as I said that this is actually from the you know the circular load principle vertical stress at point O and a depth z below its base for one sector area is nothing but q by 20 because that is we are actually talking about the one sector area into 1 minus 1 by 1 plus R1 where R is equal to R1 we are substituted now R1 by z whole square to the rise 3 by 2. Now if that left side of the circular area is actually equivalent to load intensity of q by so if you are having now when we say that this total number of numeric circles are divided into 10 so there will be total number of numeric circles are 10 and these are fixed arbitrarily by q by 10 into 20 so the influence factor for you know is nothing but 0.005q so this is the influence factor which was considered. So for the calculating the radius of the first numeric circle so if this is assumed as if the left hand side portion of this equation is assumed as the equal to 0.005q is equal to q by 20 into 1 minus 1 by 1 plus R1 by z whole square to the rise 3 by 2 by solving we get R1 by z is equal to 0.27 that means that the first numeric circle will have 0.27 times the diameter z so this is for the increase in verticals just due to an irregular shaped area loaded with an uniform load intensity and in this particular slide we have got the radius of the first numeric circle. Now if the circle is drawn with radius R1 equal to 0.27 z and the area divided into 20 area units each area unit will be produced in a vertical stress equal to 0.05q at a depth z below the center that is the meaning. Now what we do is that we take another circle where radius is R2 and R2 greater than R1 and the second concentric circle of radius be drawn and divide into 20 area units and the total stress due to area units O, B, C and B, B dash, C, C dash that is that this portion O, B dash, C dash this portion is let us assume that this portion is 0.005q we have set and this portion also we assume that is as a 0.005q. So in order to get the radius R2 now what we do is that 2 into 0.005q is equal to q by 20 into 1 minus 1 by 1 plus R2 by z whole square to the raise 3 by 2. So solving we get R2 by z is equal to 0.4 in the same way by doing for third circle 3 into 0.005q and fourth circle 4 into 0.005q similarly 10th circle 10 into 0.005q what we get is that we get the radius of the different radii of the different numeric circles. So R1, R2, R3, R4, R8, R9 so this all concentric circles radius can be calculated. Now the equation for the radius of the 10th circle is given by as I said 10 into 0.005q. So this q by 20, q by 20 is equal to 1 minus 1 by 1 plus R10 by z whole square to the raise 3 by 2 by solving we get R10 by z as infinity. So the 10th circle of the numeric chart is actually for the vertical stress is infinity. So with this we can actually get the numeric circles and the vertical stress due to irregular shaped area can be found out and here in this particular table the circle number and the radius R by z1, R by z is equal to 1, this is for first circle, second circle and the 10th circle the radius is infinity. So by knowing these values we can actually calculate construct the circles and once the more numeric chart is ready then let us say that we wanted to calculate the stress increase in stress due to circular loaded area and the point is outside the loaded area and that point has to be placed in the center of that numeric chart and what we need to calculate is that the number of sector points covered within that foundation area drawn to the scale on the generally here a transparent sheet is used or tracing paper sheet is used to draw the loaded area so that the number of sectors covering the loaded area can be calculated and with that we can actually calculate the influence that number into that influence factor into the load intensity will be able to get the increase in stress. So here in this particular slide a numeric chart is actually given where in actually we have these one first circle, second circle, third circle and this is the third the last circle which is at infinity so only the nine circles are shown here. So numeric influence chart for vertical stress and influence values per unit pressure that is 0.005. So here sigma z is equal to 0.005 qn and n is the number of influence areas covered by the suppose example we have the rectangular area so in this area what we do is that we calculate how many number of this rectangular areas are there and some approximations can be made because we cannot actually get the accurate number of the rectangular these areas. So let us say this is 1, 2, 3 like that when you count you may get the 29.5 or it can be approximate to the whole number and that number is taken multiplied into q into 0 this influence factor then we can actually get the you know first of all any loaded area if it is there the loaded area is drawn on the tracing paper to a scale such that the length of the scale line on the chart represents the depth z at which the vertical stress is required. So if z is equal to 5 meters so that the length of the scale line is actually drawn to that so the loaded area is drawn on the tracing paper, to a scale such that the length of the scale line on the chart represents the depth z at which the vertical stress is required. So depth z is accounted by making the area drawn to that particular scale. So the rolled areas drawn on the tracing paper to a scale such that the length of the scale line on the chart represents the depth z at which the vertical stress is required. So let us take a problem where a rectangular foundation having 6 meter by 3 meter carries a uniform pressure of 300 glopascals and near the surface of the soil mass. So here what we have is that determine the vertical stress at a depth 3 meter below the point A that is at this point 3 meters below this point A. So we have a rectangular area here and this point A is here and this point is 1.5 meter away from the long edge of the foundation and using the influence factors and the new marks influence chart. So by using the rectangular loaded areas so because this area is not subjected load what we have to do is that we have to use the method of superposition. So we assume that entire area is loaded now and this portion which is actually not having any load so we have to take the apply the negative loading. So by calculating the vertical stress due to these two triangles so that we will get at this particular point and minus the stress due to these two triangles with the negative loading what we get is the so called vertical stress at this point. So this minus this what we get is the vertical stress at the point. Now by using the new marks chart what we can do is that we can actually draw we need to calculate at a depth of you know this stress depth 3 meter below the point A. So with scale draw to 3 meters you can draw the area and put this point A with depth scale and put this point A at the center of the new mark chart then calculate the number of squares and with that we can actually calculate what is the increase in the stress. So the solution is calculated as explained here 2 x 300 x 0.193 minus 2 x 300 x 0.120. So this is the due to the influence factors the rectangle load area and by using the Fodden chart we have got this and using the new mark chart we get as part of artifact low Pascal which is nothing but the load area is drawn on the tracing path to the scale such that the length scale line of the chart represents the depth z is equal to 3 meters at which vertical stress is required suppose if z is equal to 5 meters then the scale of the loaded area changes. The area is positioned such that point A is at the center line of the chart and number of the influence areas are calculated in this particular case we get 30. So 0.005 x 30 x 300 we get 45 kilo Pascal. So this how you know the you can actually calculate suppose if you are having a irregular shape and that is also can be applied and calculated vertical stresses, shear stresses and the harder can be calculated. So this is another problem where the determined vertical stress increase for a point at a depth of 6 meter below the center of the invert of a newly built spread footing where you know 3 meter by 4 meter in area so we need to calculate at this particular point. So this is the 2000 kilo Newton load is given so what we need to do is that again use the method of superposition and at the center so that we can actually get the vertical stress due to this portion of the triangle and this portion of the rectangular area, this portion of the area, this portion of the area and this portion of the area and by method of superposition we can actually calculate the what is the increase in stress at this particular point. So like this we actually have the number of application problems. So we take this particular problem having a strip footing of 2 meter wide area covers in uniform pressure of 250 kilo Pascal's on the surface of the deposit of sand. The water table is at the surface and the saturated unit weight of the sand is 20 kilo 20 kilometer cube and k0 is 0.4 so determine the effective vertical and horizontal stresses at a 0.3 meter below the center of the footing before and after the application of the pressure. So before the application of the pressure you calculate vertical stress that is effective stress and multiplied by k0 value we get the horizontal stress. After loading then by applying calculating for the strip loading equation for the sigma jet we can actually calculate what is the increase in stress. So with that we can actually get before loading and after loading what are the increase in the stresses. So in this particular lecture we try to understand about the stresses due to surface loads and where in when you have got the different shapes and how we can actually use the Bosnik's theory for calculating the stresses particularly primarily we have primarily we have covered about the increase in vertical stresses. Of course there is a possibility that horizontal stresses and the shear stresses also can be calculated. And so these stresses cause the settlements in the soil and also undergoes the volume changes can takes place. So further we actually look into the concepts of how this loaded areas cause the increase in the consolidation and or if the consolidation does not happen how we can actually accelerate the consolidation so that the settlements before the constructional structure can be anticipated.


if only if it's closed do we error and then up here close is going to set end of file and close to true and it's going to notify exit end of file is going to set end of file to true but not closed and will not notify exit because it could notify exit but it's not clear that it matters yeah exit status zero so i guess now what we do is um ooh let's be extra fancy here and do that command is going to be equal to this and we're going to do actually we're going to not move command just so we can choose what command to run as an argument to the file hello okay so that worked fine and then the question is if we run like bin false we get exit status one and no output great so this means that now we have exit status working uh and exit status so the question now i think is whether we want to deal with the standard error or whether we want to try to get rid of the handle dot spawn you guys have a preference we can try either i think getting rid of handle dot spawn will be a little bit harder but it might be instructive okay well i want to get rid of handle dot spawn so let's get rid of handle dot spawn um oh fudge nuts that's only true if it's only true if session can be pulled hmm that's kind of awkward actually no uh we can still call poll handle spawn please all right so we're doing handle dot spawn okay so so the trick let's see uh the reason we're running into trouble is because uh the connection is owned which means that we can't have multiple pointers to it that's basically the issue um and the reason we need multiple pointers to it is because we sort of we want one that just ensures the connection keeps being pulled in the background while you're trying to pull other things uh but we also want to continue having a reference to it so that we can do things like open new channels um i think the way we're going to have to get around this is we're going to wrap it in an rc ref cell so that we can have multiple pointers to it uh we're going to spawn one thing that has a copy of it and that copy is going to um just call poll because poll takes a mute self no it does not consume self um and then for the other methods which is for us currently is basically just channel open session for channel open session instead of using the one that's on connection we will implement it ourselves using the one that's on uh sorry instead of using the one that's on channel on connection we will use the one that's on uh session which takes a mute self uh now we of course then need to implement the logic for waiting for confirmed ourselves but in theory that shouldn't be pretty straightforward yeah this just gives you a future that my guess is just waits what's first round it's a good question i feel like we should just try and see what happens but the essentially i don't know whether session is something we're supposed to deal with ourselves like i i don't know if it's okay for us to use the methods down here immediately by the confirmed the corresponding channel is there like a channel there's a channel open which is a future that resolves into one is there something else as well like a channel the channel here seems oh channel confirmed has the other side confirmed the channel okay that seems unhelpful um i think we basically just need to look at the implementation of channel open this does a bunch of stuff so the poll here basically just keeps polling until until channel is open is true so the question is when is channel is open sector true because what i really want to do is i notice that on handler there's a channel open confirmation so what i'm imagining is that when this is called on the handler like right after this is called on the handler then we can start using the channel right that's how i imagined that that works which would mean that all our channel open future would do is it would check it would we would basically keep a similar kind of tracker maybe even in channel state saying like ready and if it is not ready then it will sort of register its task for a wake up and then in the implementation of uh channel open confirmation we will set ready to true and then trigger that task so this is a similar kind of thing we did for reads right um and that i and then we will just resolve the future whenever confirmed has been set to true but i'm a little bit worried about this channel open future doing other things i don't know what this first round thing is see here the connection the first thing it does when you try to open a connection is a board read there's a board read something we have access to i don't think so no it doesn't look like it um i assume this is like something along the lines of the connection is currently or the the connection is generally in a state of waiting for stuff from the server and this is a way to tell it hey look uh stop trying to read stuff from the server because we're trying to send something um but it's a little bit unfortunate because uh we can't call this method let me think about that sorry i just have to go to the bathroom i'll be back okay yeah so the question is what does a board read do because these other things don't seem important it like ensures that it calls pole in the underlying connection oh so it does pull the underlying connection yeah this is basically it getting around spawning is that the channel open sort of has access to the underlying pole and just like can keep calling that this would this would also be unnecessary if the if uh thrush itself spawned the underlying connection okay so i think all the rest of this i don't know what this is reading businesses c dot is reading so it seems like the connection can be sort of in a state where it is reading and that's what that abort read does too so we're gonna have to figure out what that is all right so let's um it's a little bit annoying that the code isn't like easily available connection so is so it is public so we can't call it it's just hidden what this does but seems like we have to call it's a little bit unfortunate that we have to reach this far into the internals makes me a little bit sad the problem of course is if like if imagine that this implementation changed our implementation also has to change to match that but i guess in those cases the abort read method would probably go away but okay so let's uh get rid of that so what we're going to do now is we are i mean this is essentially us re-implementing the connection part of thrush and just using the session stuff but all right um when you create a new stream you are going to have to also give a handle which is going to be a tokyo reactor handle um we're going to take the connection that we get so this is now a session at this point we want to disconnection actually d ref mute as well because otherwise we have a bit of an issue uh because we're going to need mutable references to the session it implements d ref target session and implements d ref mute great okay um so in that case we should be able to make a let's just use a type alias here this is going to be uh takes an s and it's one of these guys but specifically it is an rc ref cell of that and that's what session is now going to contain so we're going to have one c that we're going to spawn uh i guess we're we're just going to do rc this is the connection this is the thrush connection right so we're going to wrap that in an rc new and ref cell uh we're going to take one of them and we're going to spawn it and i think it's this should be spawnable because you can call pole uh might i think a future is required to oh let's see what happens okay so we're going to thread spawn c dot com this is not actually going to work we're probably going to have to implement future for a wrapper type um it's not thread spawn but handle dot spawn um and then we are going to give back a this we're going to map out the c and now when you try to call wait we don't actually want to do this here we want to do this uh yeah we don't actually want to do this here we want to do this when you make a session not when you make a new session so here i think we're just going to take the handle i'm just gonna do c handle dot clone not do this yet yeah let's do this later okay so this means that new session is going to go back to having a connection or a c i guess um and a handle it's going to be a tokyo reactor handle and so now this is going to map the c into a new session c handle nice handle is going to be handle dot clone um yeah and then fn from u is going to take a new session no it's going to take a uh it's a little bit awkward for this to be called make but all right uh so this is going to take a existing thrush connection and a handle wrap the connection in rc ref cell so that we can spawn one copy and keep another um and that other is what we're going to use when we later open xx okay so make is going to take the uh connection that way this can hold a c and this can hold this so this takes a c s and a handle and gives a self and it wraps it and then returns a session so this is of course initially not going to compile it all in part because i'm being silly now authenticate key is going to not just map the session it's going to take the connection it's going to extract the handle it's going to call authenticate key on the connection move in the handle and when it creates the session uh it will make that from the resulting connection and the handle uh and then when we get one we do this and now open xx is probably not going to work handle doesn't work because handle not found and also unused import yeah so the issue now of course is uh that down here we're trying to spawn uh a clone of an rc ref cell connection which doesn't implement future we know it implements future but it sort of needs to implement future by borrow muting the thing under it which won't work so what we're going to have to do is we're going to have to make a rough that's going to be like a uh a shareable connect takes an s which is an async read and an async write and just source the c of s stores an rc ref cell implement future for that and luckily this is pretty straightforward because all it really has to do is borrow the inner uh now note that we need to be careful here because borrow mute is like runtime borrow checking right um and so this wouldn't work if the thing if the when we call pole on the underlying connection that pole ends up trying to borrow the connection mutably right because then you would end up with two mutable references at the same time uh and so this basically means that our handler is not allowed to have a um a c s it is not okay for it to have a c s at all like it it's not allowed to keep a reference to the connection or it could but it would never be able to use it because all of our handler methods are called in the context of polling the connection which means that we're holding a mutable borrow to the connection i think this would be fine because i don't think any of these need access to the connection so i think we're fine uh but it's just worth keeping in mind what we call this session state ref session state ref handler cannot uh okay so now uh this shareable connection should be portable which means that we can now spawn it uh it can't i guess really this should be uh this is now a shareable connection we also want to this is similar to the other case where we have a um a sort of ref where we we want to be able to get to the session given a shareable connection actually let's not do that sorry uh okay so we now have a connection that we can spawn that is a future that will um that will keep polling the underlying connection but we also still have a pointer to the connection itself which means that in theory we should be able to do open exit of course now if you try to check this it's gonna yell at us because oh this is the tcp stuff again we only implement this if this is also oh that's right i forgot about this um so derive clone is a little bit stupid sometimes derive clone um when you have a type that's generic over some type parameters will only implement clone when s is when the type parameters are also themselves clone so it will generate something like implement s clone for shareable connection s where s is the existing trade bounds plus clone however in our case we do not actually need s to be cloned for shareable connection to be cloned the rc takes care of that right so we want to generate this input um which derive clone will not do for us so we need to do it ourselves we'll just be uh shareable connection self dot zero dot clone because we need to be able to spawn it even better so remember when we spawn a thing it needs to um a spawned future needs to not produce any errors or any output because it will just like be tossed into the void right um but now that we implement future ourselves here what we can do is we can do uh is we can keep track of the error so that we can return it from all the channels if an error does indeed occur so finally we got the thing that we wanted originally which is here um if pole finishes so it exits with like okay then we return okay if it exits with error e so this would be a handler error then what we do is we do self dot zero dot borrow dot uh what does handler require dot handler mute the handler is already an rc so borrow is fine handler is fine so remember this is really a session state right so this is state and then state is going to be state dot borrow mute which gives us a mutable borrow to the the underlying session state and on that state we can now say error width is sum of error here error width is going to be a option of thrush handler error of no error and then we're going to swallow that error right because now we've sort of stored it um and so we're now the the spawned future what it really will do is it will it will pull the connection and if the connection returned an error when we pulled it we'll store that error and then pretend like it didn't happen this is important because now we have the error in the session state which means that reads and exits that is and such can look at that error if we wanted them to do this now needs to implement a 205 session c right so this will now actually hold an i guess a shareable connection and now it's going to complain because yeah so now we get into the funny business here of open exec now uh channel open session the one we're using either we need to use channel open session on here which is what we were using which consumes self and gives us back this nice future thing or in our case now we're going to call a channel open session on the underlying session which is not a future just gives us a channel id and then we need to deal with it ourselves um and so the compiler is now saying hey there is no method channel open session the reason for that of course is that this is now just uh this is now an rc ref cell right so if we do a session it's going to be this dot for me i'm going to say session is session dot dereft right which is going to give us the underlying session we don't really care about the connection anymore because there are no um really all that useful methods here oh channel closes another we need to deal with we don't write to any channel so it's fine for now but if we this does mean that if we currently were to try to execute say the cap command it will never exit because we don't send a no file from our side uh okay so session is going to be dereft and now we're going to do now we're going to be using the channel open session on session so we're going to say channel id is session dot channel open session this does need to become a future at some point oh right that's what we're doing so handler we're going to have to implement channel open confirmation so here uh we're going to have to like uh notify channel open which means that down here what we really want to do is we want to make a channel open future which is a thing we haven't defined yet um and that's going to keep track of this channel id and probably also needs the state would be my guess uh so state is going to be session dot handler dot clone so channel open session is going to give us a channel id immediately so if we look at look at the method um channel open session uh return some immediately if the connection is authenticated we know that it's already authenticated and then it will only become uh usable later so this will return immediately it might return an error though so i guess we will do futures failed i think that should work okay so now we have a channel open future and oh that's right we did all sorts of weird things here didn't we this doesn't mean that open exec no longer needs to return the session it can just return a future channel because it just takes a rec self right so what this enables is that you can call open exec and that gives you that gives you one future that's going to give you a channel you call it again that gives you a second one i guess this does actually require mute self because you can't open two channels literally at the same time i guess given that this type isn't send is not an issue but just for correctness sake you are sort of modifying the session when you add a channel to it right this gives us one of these and then i think we don't even need the i think this command needs to go here now i think we just do box new on this and then we're gonna have to have this um we're gonna have to have a pub struct channel open future it's gonna have to take a lifetime for the command and it takes basically the same thing as all these other things done here and then we're gonna have to implement future for it and now we're not gonna need it for session anymore so that's kind of nice um channel open future does not need all the s stuff um it can't even return an error i think no it can this would be error width right so this would be the same thing as we have above um this thing it's going to be very similar to the channel stuff that we did for all the other things right it's going to be we're going to check whether the upstream state has changed for this id i guess actually we'll end up putting this state in immediately yeah so here we immediately construct state for this new channel it's going to be default by initially um this can go away and we're going to pull down here so in poll we check the state um we set connect to notify to none um if state.confirmed so this means that now the callback up here has worked out right like if this callback has been made for this channel um then we can return ready and in particular we want to return a ready of channel uh where state is oh that's awkward it's still self dot state except it we have it borrowed mutably which is a little awkward non-licical lifetimes would fix this um and id is going to be self dot id if is there um handler like channel open failure we need that one too so channel open failure so it's also going to have to notify us about this um so this might error depending on what the state of the channel that we opened is otherwise we're going to do the same thing as we did the all the other ones which is going to be uh open not notify and not ready so this means that a channel state now has an open notify you're starting to see a pattern here open notify it's going to have a I guess really we should group these someone so this should go here these are all related this is related and this is related and this should be open state it's going to be an option uh well it's sort of like an option option which is a little weird it's like it's some if we got a response and the inner is some if there was an error so I guess really it's more like an option result nothing and a rush which of course initially is close to false uh there's none they just started that open notify so here we're going to do we're going to be open state dot take if we got some okay then that means that great the channel is ready if we got some error e that means that we got an error uh and I guess this is this could be a handler but let's just ignore that for now there's going to be a channel open failure um and if we got none that means we're not yet ready and so that pattern makes sense it's like basically the same pattern as we had for for exit oh and I guess once this is the case here we sort of want to exec again so the question is whether we're allowed to call that from here so remember how we can't have this have a we can't have things in handler have a reference to the connection because we're going to mutably borrow the connection when we're pulling it the question is whether in this poll can we have a reference to the connection I think we can the reason we need one is to so that we can call exec I'm pretty sure we can because this poll is not called from within this poll so I think we should be fine I think this means that this is going to have to have a session as well which is going to be a shared connection which means it has to be generic or s so that if this happens we do uh session self dot session dot borrow dot and and what does how does exec not return anything I think that's so weird self dot id true this and then it returns that hey uh this takes an s that's true asian greed plus asian right 45 is going to return no longer one of these but instead a channel open feature on this may no longer need tcp 267 zero p is channel id and it also needs what was the other thing we found it also needs a session self dot zero it's a good question we could have yeah so so the observation here is that open exec sort of almost synchronously calls uh channel open session which returns a result which will return some immediately I think this is meant to say okay um and we know that it's authenticated so I think we can unwrap here sessions this should no longer be a box yay dot zero dot zero I don't think you're allowed to do that yeah I don't think this what I think this needs to be like this or something this has to this has to do the same thing as all of these things are doing which is cut the state for that channel and then it has to set state dot open state is some okay in this case because we got a confirmation and then it needs to notify the open waiters and then failure needs to do sort of the same except it needs to store an error of the reason oh this is a description in language we're just ignoring those for now I guess we're ignoring this one too unmatched types 76 oh this needs to also return this business oh right this has to be we specifically want the one for the session not for the connection 290 this is not allowed to return that that's false this should return all right borough checker tell me what I did wrong uh can't move self that's because we don't have no lexical lifetimes yet so we need to do this and borrowed value does not live long enough just need to keep the lifetimes alive and now it's going to give me the one that is annoying to fix which is that here we've taken okay so this is in the poll of channel open future where we sort of take the state oh can we get around this maybe so the problem is here we have a reference to the channel state and then at the same time we're trying to move out of that state right because so we we have this borough here that's into the state and then down here we're trying to move out of self dot state it turns out though that we can get around this by okay so in theory we haven't actually changed anything except that you should now no longer need to do the spawning business the example won't compile because now needs a handle so it's going to be given a connection and it needs to call new with a connection and a handle all right and the open exec here gives us a has an error type that's different from the one that like it's no longer a handler error right this is where we would probably pull out the failure crate and then make just all the errors be error because they should all be uncommon in this case I think what we'll do is we will instead just do make this a handler error and then we're going to here do just wrap it in an error what are the different error types here again actually that's a good question keys error can I actually reuse any of these that's a little weird what is what does channel open give the channel open thing handler error how does it turn an error into a handler error that's what I want to know apparently it just doesn't so it ignores the thing that's given to the handler the actual error description we get well in that case we are going to make it an IO because IO is easy to fudge with it's going to be an error kind of other and it's going to wrap me except we're not allowed to do that because it this error type does not implement where's it channel open failure does not implement standard error so there's no way for me to expose this error type inside of a handler error okay I'm going to make you all really mad at me and do this not worth the time that's an error right okay so in our example I'm 27 yeah that's right this no longer needs to map away anything can just do this let's see if this does the right thing oh we forgot to do the board read stuff so this was like oh I guess we have the code here right so there's a first round field and first round has to be true and then here this has to be like a if self first round and then the connection session I think so and channel is open should just like clearly be true here but I guess we can we can double check so so s is one of these we're gonna do like an almost like an assert yes s.channel is open channel.id self.session and I can't borrow mute because session.zero so now we're like sort of doing the same thing as this is doing I just like don't believe that this is necessary it's really weird this like is reading I don't actually know how to deal with that yeah because this seems to like not do the right thing at all hmm that's a little sad because it also suggests that it's not that it doesn't get where we want it to see how far it gets actually oh I guess it's a little bit tricky for us to do that but in theory it should at least get to here trying to open is this roughly makes sense I know we're are pretty deep in the weeds here but I did tell you that some of this is gonna get a little bit ugly because it does get to that you shouldn't normally have to abort read you sure because that's what this code over here is doing I mean I'm very happy if I don't have to abort read but essentially we're writing our own implementation of channel open right because we sort of have to yeah I mean the the the thing to think about for Tokyo in futures is is that it's it's just to get the model right in your head so that's why the the article by Aaron Turin is one that's useful to read if you want to get up on the basics as we're not having to call this normally I agree but we are actually we're re-implementing channel open because the only way to get a channel open from thrush is to have a to consume connection to consume a connection whereas all we have is a ref mute like we have a mutable reference to a connection I need to make one so we do actually need to implement this ourselves no that's fine we are again we've like done a pretty deep dive here so I think the right thing for us to do is to call abort read here I don't think this should be necessary it's like checking whether it's open because we only return it once the confirmation has come in right so once this method has been called on the handler when that that method has been called on the handler that's when we return the channel so the question is it's still necessary to check these two and I don't think that's the case but this code I'm not super familiar with like this is thrush code right like deep thrush code the more concerning part actually is that it's um is that this just hangs so do we get a channel at all is the other question we do get a channel this log is three misspelled it do I need like this I don't think I need that this oh I need to invent it logger that's why so we did get a channel so it's stuck somewhere else specifically it gets oh so that actually sort of suggests that things are working it just suggests that the spawn isn't working show that screen again yes I can am I hearing clear mx clear switches so I think these are clears actually no they might be browns this is the um the filco ninja but are they clear that's a good question switch it's definitely not black brown yeah that makes brown uh sorry it's telling you it started to wait for packets yes which is sort of what we wanted to do however um yeah the concern is that we now have a channel open right like the we did in fact this this future resolved which means we did get the channel back um but we aren't able to read from it so this means that this read never returned something useful which probably means that the underlying session isn't being pulled so I'll be here uh I know the abort read happens earlier the abort read is uh the abort read happens uh when we the first time we pulled the channel open future yeah so see here the issue is that the ssh connection is not being pulled after we got the channel hmm this almost suggests to me that the hmm I wonder if it's already gotten the day it's just like print out some things yeah exactly but we do get the confirmation right because the channel open future does resolve so we open the channel pull the ssh connection for a bit then we get the channel back but after that there are no more calls to pull on the ssh connection do I need to do something to like re-enable reads after this has been opened basically I enter this right like uh this reading it's only considered open if C is reading so then why is it not being pulled anymore this does explicitly call pull but only if it doesn't get a channel we do get the channel we basically go through this loop like basically once I could check I guess but um once this returns so it really is the read then that fails so let's just check that read is actually called so we should see we should see it say not yet at least yeah this is almost like the the ssh connection is not being marked as runnable once the channel has opened I wonder whether uh the channel open needs to explicitly call pull I don't think it should be necessary but let's see okay so so for the um channel open when we get here so many times this goes through that's a little interesting yeah once it gets the channel the last time it doesn't pull the connection anymore so I almost wonder whether we like need to do a pull here but it shouldn't be necessary but I guess we can try it we would have to draw to do this after you get the channel the only thing to do is to start using it no but I'm trying to read from it I'm not trying to send anything right I'm opening the channel and then reading from it so there shouldn't be a need to do like this calls exec right so I do do something with it so when this is exec when this is exec like doesn't do anything but I don't see why that would be the case oh if I don't call pull the exec doesn't send anything right so that's probably why s.exec because I'm only using the session here this probably um so I'm calling exec on the session but there's nothing that triggers that to be sent over the wire so that's totally why so this needs to so I wonder whether this needs to call pull sorry self dot uh session which is all sorts of weird because what if this errors I guess it has to be this and this requires tcd oh that's right and this I guess really all it needs to do is wake up the the task is really what it should do that should be sufficient for pull to be called eventually so really what we're saying here is something like this is going to be a struct now it's going to be a a connection it's going to have a c it's also going to have a it's going to be a option yeah that's zero dot borrow dot c dot so this is going to be the connection is going to be this so basically we need to keep track of which task is responsible for pulling because given that we spawned it and then we need to sort of poke that task once we exit so this is I guess this is the the weird part about using session is that session is just like queuing things and doesn't do any work so we would do something like c dot task is some futures task current and then we would pull c dot c or something right because now down here uh connection and this will now be I guess s dot s dot task dot unwrap dot I think so yeah so so now um and then it's going to complain about lots of things any same three handler c seven type connection cannot be derelict and this is now going to be session dot zero borrow me dot c connection c these kinds of like mechanical changes are c dot handler 37 I guess this could just have a thrush but sure why not 320 finally yeah the problem here is oh I guess now we don't need to do this anymore because we're not calling pole directly here right so in theory this should now sort of um ready up the thread that manages the connection so the the thing that we spawn there we go so basically this this pokes the thread that's responsible for doing all the IO on the thread um so it pokes that thread after we call exec so that it actually sends that exit command it is a little bit weird um that we have to do that like in a sense I wish that exec would cause those notifications to happen but I guess it's not terribly surprising that it doesn't uh okay so that's nice now we got exactly the API we wanted right it's pretty neat in theory now we should be able to do writes pretty easily actually but all this should come oh and yeah so so the other thing that's uh that we should think about here is the errors uh that we now store so because we ended up choosing to do this slightly differently now um any error that happens during the connection uh we store and so the question is where do we return that error uh so this is the resort channels yeah so session state has this error with which is while we're polling the main loop of the connection so the things that does IO what if an error happens there then what happens um currently that error isn't returned from anywhere but arguably it should be the question is just where because currently oh I guess here's what we'll do we'll have um we'll have a method on session that you can ask for an error I think this is actually the the API that we want specifically um you can have a bunch of channels and if some of them return prematurely like return and you weren't expecting them to return um then you would call this method and you would get what the error was I think that's actually the API we wanted so this means that on a session uh there's now a method that you can call uh that's like uh I guess which gives you an option chandler error which itself dot last error uh no a session just has a shareable connection so borrow mute dot a shareable connection has a connection which has a C oh I guess really what we need here is the state don't we um it's no longer sufficient to just store hmm well I guess you can get to it in a really roundabout way so we can we can uh say that the the connection is going to be self dot zero dot borrow and then the handler is going to the handler is going to be connection dot handler the state is going to be is it true self dot zero dot borrow yeah but the real connection is going to be uh connection dot no actually a handler is going to be connection dot c dot handler the state is in the handler so we're going to have to do handler dot borrow dot zero dot borrow mute so that gives us a state through the handler uh and then we will take I think maybe time us this up probably uh shareable connection zero dot c dot borrow did you mean zero probably oh yeah I did we should probably not have as many new types this is the problem with the new type pattern so this is a new state which returns last error yeah so now in theory if there was an error on the connection so if all your reads suddenly like returned early but they all returned okay right they just returned incomplete results you can now ask the session what went wrong so that seems nice and then I guess now we're doing writing that seems like actually oh let's see it pointed it's getting pretty late um okay let's see how hard writing will be and then I may have to cut this at some point okay so we're going to implement async write for channel somehow uh actually async write for channel we can probably do pretty easily right isn't async for channel just uh in session there's a thing I saw a thing on session where you at uh connection there's a channel close which I think is what we'll want to call except we can't actually call it because all we have is a session so we're really going to call it's something like channel is there a channel close here really I guess channel end of file is really what we'll send I don't know if that's what shutdown is intended for in async write but that's my guess um okay so we're implementing write for channel so write for channel is going to have flush and write uh the layout is going to be fairly similar than as to reads but um we're going to have to do let's see that's a very good question we're going to be calling data aren't we yeah we're going to be calling this and remember that actually this is going to run into the same thing as we had previously of um of we will have to notify the task that maintains the connection right so this is the same thing that we found out that we had to do for channel open it's actually really convenient that we found out because we're going to have to do the same for writes um luckily a write is fairly straightforward I think so for a write uh what we really do is we um we need to get at the session and the session oh yeah let's suggest the channel does indeed need to have a reference to the shared connection bearable connection nope not there there's there's channel which means that this does indeed need to have the stream this is so that the channel has the ability to uh send data it needs to have access to the underlying session so that it can access the session buffers essentially with the sending pipeline um so a channel is going to have a con this means that now it's going to be able to do self dot con dot uh zero dot borrow mute so this is going to be the connection um and then on that connection we're going to call specifically on the session that we get under there we're going to call data with the self dot id with no specific channel and with some amount of data which is going to be buff in fact I guess write never blocks here just a little weird oh I guess the blocking would actually happen in flush it's maybe a little weird I don't know how that's intended to work because here you could imagine that a writer just like keeps writing oh I guess actually n being zero implies that it would block yeah so if n is zero and buff and and not buff dot is empty uh then this is really an okay sorry and this is a woodblock so this would be a we're gonna need a write notify otherwise we just happily return an okay there are no other things that can happen here uh yeah exactly but we need to apply so the observation is that data never blocks it fills a buffer instead but we do need to apply some back pressure so presumably there's some window on the data connection or something right so it could be the data uh yeah this could presumably return zero to indicate that it didn't read any bytes or it's not willing to put any more bytes in the window right and so if it put no bytes in the window that's sort of the same as saying a right woodblock that's that's how we're gonna interpret it here if we didn't do this if we just returned okay zero then um the writer would probably just spin calling this method right um and so we would rather uh sort of say we would have blocked and then notify this task instead when space is available in the window which I assume that we learn here window adjusted right I guess maybe it's not window adjusted so a way for me to tell the data has been sent I feel like it probably would be window adjusted because okay if this doesn't trigger whenever data is sent uh then we will have to just return okay zero here okay let's leave that as a revisit later yeah so in a sense this is about uh keeping track of the window to avoid saturation right it's that otherwise the client would just like keep pushing data if nothing's pushing back I guess the other way to deal with this would just be to indeed just return okay zero I don't think we want to do that um this does however have to uh if we did write some bytes then this needs to poke the um the thread again the sending thread so where's our channel open future over here so this is going to do something like oh I guess we already have the con so it's going to be you could write a flush plus pull the flush this would try to send something to the socket yeah I guess that's one way to do that I sort of want to avoid explicitly calling poll but I guess I could and then see whether that would block um yeah so so the suggestion is that we uh here maybe call poll on connection um see if it would block but that brings us into some other issues too of like now we're calling poll inside of an asynchronous write um it also means that we would be um we might be writing data for an entirely different connection so it blocking isn't that interesting yeah we'll have to see exactly what we do here it might be that okay zero is the right thing to do um okay and then I guess flush here is going to do something like is there a flush call I assume so but the flush here as you observe is like sort of weird it flushes the clear text buffer into the encryption buffer the question is can I also do a flush I guess the issue is that I there isn't really a way to flush a particular channel because if there's like a single thing that keeps track of all the buffers that is going to write then flush would mean send all the data to all of the channels because I don't really have control over the individual um channel buffers so this one's a little awkward actually yeah in fact that one's a little bit weird it's also like I don't know how to wake these up again if the handler isn't notified that there's now space on the connection yeah the back pressure here is tricky I don't know how we're gonna do that yeah it's gonna be a little bit tough I think um what we're actually gonna do here is uh I think I'm gonna there's a single buffer for the entire connection yeah exactly so this would mean that there isn't really a notion of flushing a single channel a flush would flush everything um and I don't think that's what we want um so the stream is getting pretty long I think uh and I think this will actually take a while to fix so I think we're gonna cut things here um and then we can uh yeah I guess we'll do another session where we deal with where we deal with writes uh I think writes is the biggest thing remaining I guess writes in like standard error which should be pretty straightforward um and then we'll do a session after that or maybe in the same one depending on how long write ends up taking um we can do a session on uh integrating this into which was the original intention integrating this into tsunamis so the tsunami becomes asynchronous um but that's sort of one step further down the line uh and then converting to Tokyo and futures the the new Tokyo crate and the future 0.2 that should be a very straightforward transformation uh we might even do that as a part of the next stream because hopefully writes should take a lot less time than doing all the rest of this great because the rest of this great was a lot about setting up the infrastructure for the crate right um so yeah let's see the intended way is the data flush and then connection poll yeah it's going to be a little bit tough to do that here but we might be able to I mean in theory we can call connection poll from here it's just uh we'll have to be a little bit careful about the boroughs but I think we can make that work okay in any case I think we'll stop it there and then we'll do uh writes and writes and standard error and Tokyo upstream Tokyo and future 0.2 in a new video and then in the third probably will end up actually upgrading tsunami um yeah I think that's the plan um I'll post this video to to YouTube sometime in not too long hopefully once I sort of get home um and then sorry once I get to a place that has a decent network connection and then once that's been done I will post the twitter post the patreon uh and then I'll announce upcoming streams on twitter and patreon too um thanks for joining in it's been fun bye