Drift Diffuion 1D Solver
Drift Diffuion 1D Solver
%% Solve MOL ODEs system with WENO5 fluxes using ODE45 solver
disp('Wait...'); tic;
[TT, U] = ode45(@eq_sys, t, n0*ones(1,2*nx));
disp(['Complete after ', num2str(toc/60,0), ' minutes!']);
%% Plot all results
figure('units','normalized','outerposition',[0 0 1 1]);
set(gcf, 'doublebuffer', 'on');
ne = U(:, 1:nx); ni = U(:, (nx+1):2*nx);
for I=1:length(t)
subplot(2,1,1)
plot(X, ne(I, :), 'r-', X, ni(I, :), 'b-', 'LineWidth', 2);
xlim([0.0 d]); ylim([0 n0*1.1]);
title(['Concentrations at t = ', num2str(t(I))], 'FontSize', 16);
xlabel('cm', 'FontSize', 16); ylabel('cm^{-3}', 'FontSize', 16);
legend('n_e(x,t)', 'n_i(x,t)', 'Location', 'SouthEast');
grid on;
subplot(2,1,2)
plot(X, Electric_field(X, ne(I, :), ni(I, :), t(I)), 'r-', 'LineWidth', 2);
title('Electric field strength', 'FontSize', 16);
xlabel('cm', 'FontSize', 16); ylabel('V/cm', 'FontSize', 16);
grid on;
drawnow;
end