/* beam2.c ordinary differential equation for a loaded beam */ /* handle Neumann boundary dy/dx=0 at x=0 and x=L better */ /* given a beam of length L, from 0 < x < L * with Young's Modulus of E * with moment of inertia I * with p(x) being the load density e.g. force per unit length * with both ends fixed, meaning: * y=0 at x=0, y=0 at x=L, dy/dx=0 at x=0, dy/dx=0 at x=L * then the differential equation that defines the y position of * the beam at every x coordinate is * * d^4 y * EI ----- = p(x) with the convention for downward is negative * dx^4 * * for uniformly distributed force (weight) p(x) becomes - W/L * This simple case can be integrated and solved analytically: * * d^4 y * EI ----- = -W/L * dx^4 * * d^3 y * EI ----- = -W/L x + A ( A is constant of integration, value found later) * dx^3 * * d^2 y * EI ----- = -W/L x^2/2 + A x + B * dx^2 * * dy * EI -- = -W/L x^3/6 + A x^2/2 + B x + C we see C=0 because dy/dx=0 at x=0 * dx * * EI y = -W/L x^4/24 + A x^3/6 + B x^2/2 + D we see D=0 because y=0 at x=0 * * substituting y=0 at x=L in the equation above gives * * 0 = -W/L L^4/24 + A L^3/6 + B L^2/2 * * substituting dy/dx=0 at x=L in the equation above the above gives * * 0 = -W/L L^3/6 + A L^2/2 + B L * * solving two equations in two unknowns A = W/2 B = - WL/12 * then substituting for A and B in EI y = ... and combining terms * * W * y = -------- x^2 (x-L)^2 * 24 L EI * * The known solution for a specific case is valuable to check your * programming of a numerical solution before computing a more * general case of p(x) where no closed form solution may exists. */ #include #include #undef y1 #undef abs #define abs(x) (((x)<0.0)?(-(x)):(x)) /* the right hand side of d^4 y / dx^4 uniform load */ #define F1(x,y) (-W/(L*E*I)) void simeq(int n, double A[], double Y[], double X[]); static double E = 10.0; /* arbitrary constants, values and units can be found*/ static double I = 9.0; static double W = 7.0; static double L = 8.0; static void difeq(); int main(int argc, char *argv[]) { double x, y, h, slope; double k1,k2,k3,k4; double y4, y3, y2, y1; int i, n; printf("beam2.c running \n"); n = 9; h = L/(double)(n-1); printf("E=%g, I=%g, W=%g, L=%g, h=%g, n=%d \n", E, I, W, L, h, n); printf("\nAnalytic Solution.\n"); for(i=0; i