← Indietro
EserciziCompleti

Notes for exercises

Completi di Mathematical and Numerical Methods in Engineering per il corso di Biomedical Engineering presso Politecnico di Milano. Materiale proveniente dall’archivio storico Studwiz e classificato per la consultazione online.

Mathematical and Numerical Methods in EngineeringCompleti

Informazioni sul documento

Cosa trovi in questo materiale

Completi di Mathematical and Numerical Methods in Engineering per il corso di Biomedical Engineering presso Politecnico di Milano. Materiale proveniente dall’archivio storico Studwiz e classificato per la consultazione online.

Qualità dell’importazione: il testo è stato estratto direttamente dal documento originale.

Contenuti estratti dal documento

Passaggi rappresentativi riconosciuti nelle diverse parti del materiale. Il testo completo resta presente nella pagina per la ricerca, mentre l’anteprima compatta rende più semplice la lettura.

Pagina 1

NOTES FOR EXERCICES M&N METHODS – NUMERICAL PART MATLAB EXERCICES Order of accuracy: 𝑝=log!&"##(%,'()!"##*"#,$%#+!&'' , 𝑒𝑟𝑟,=|𝑢,−𝑢"-./((𝑥,)| i=1,…,M-1 are NOT the nodes but the halvings of the discretization step h for j = 1:M [t, u] = method(t0, tf, u0, dt, lambda,…); e(j) = max( abs(u – u_ex) ); dt = dt/2; end p = log2( e(1:end-1) ./ e(2:end) ); Transport eq.: • FE/C unew(2:(Nh-1)) = u(2:Nh-1) - CFL/2*( u(3:Nh) - u(1:Nh-2) ) % Boundary condition unew(1) = Uinflow; % Inflow unew(Nh) = (1-CFL)*u(Nh) + CFL*u(Nh-1); % Outflow (UW) • BE/C A = speye(Nh-1) + spdiags([-e, e], [-1, 1], Nh-1, Nh-1); for n = 1:Nt-1 t = t+dt; F(2:Nh-1) = u(3:Nh); F(1) = u(2) + 0.5*a*lambda*Uinflow; % BE step unew(2:Nh) = A\F; unew(1) = Uinflow; end • Upwind unew(2:Nh) = (1-CFL)*u(2:Nh) + CFL*u(1:Nh-1); % Boundary condition unew(1) = Uinflow; % Inflow • Lax-Friedrich unew(2:Nh-1) = 1/2*(u(3:Nh)+u(1:Nh-2)) - CFL/2*(u(3:Nh) - u(1:Nh-2)) % Boundary condition unew(1) = Uinflow; % Inflow unew(Nh) = (1-CFL)*u(Nh) + CFL*u(Nh-1); % Outflow • Lax-Wendroff k = a^2 * dt^2 unew(2:(Nh-1)) = u(2:Nh-1) - CFL/2 * ( u(3:Nh) - u(1:Nh-2) ) ... + k/(2*h^2) * ( u(3:Nh) - 2*u(2:Nh-1) + u(1:Nh-2) ) % Boundary condition unew(1) = Uinflow; % Inflow unew(Nh) = (1-CFL)*u(Nh) + CFL*u(Nh-1); % Outflow N.B. In LW scheme: Upwind: k = abs(a) * h * dt Law-Friedrich: k = h^2 Heat eq.: A = (h^(-2))*spdiags([-e, 2*e, -e], [-1, 0, 1], M-1, M-1); % Initial and boundary conditions u(:, 1) = y0(x, t0); u(1, :) = 0; u(end, :) = 0; % Theta method applied to the internal nodes I = speye(M-1); for n = 1:N u(2:end-1, n+1) = ... (I + dt*theta*A) \ ((I - dt*(1-theta)*A)*u(2:end-1, n)); end • FE theta = 0 • BE theta = 1 • CN theta = 1/2 Poisson eq.: • Dirichlet BC A = spdiags([-e, 2*e, -e], [-1, 0, 1] , M-1, M-1)/(h^2); F = f(x(2:end-1))';…

Anteprima

Prima pagina del documento.

Prima pagina: Notes for exercises