How do I implement Neumann boundary conditions for a specified time period of a model?
16 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I'm modelling the movement of ions within a cylindrical space in MAtlabs PDE Toolbox and need to have flux of ions across one face of the cylinder (F1) for the first millisecond of the model run, but then the boundary condition must be 0 for the rest of the run. The F1_Flux component defines the boundary conditions for two separate equations modelling two different ions, the first one is always zero
My current code for this boundary condition is as follows:
F1_Flux = [0,-1.34e-23];
applyBoundaryCondition(model,"neumann","Face",1,"g",F1_Flux,"q",0);
This code obviously applies a flux for the entire run, I just wanted to know if it was possible for this to only be applied for 1ms and then have it set to zero
0 comentarios
Respuestas (1)
Nipun
el 24 de En. de 2024
Hi Joshua
I understand that you are trying to model the movement of ions in a cylindrical space using MATLAB PDE toolbox but are facing an issue with applying flux for a specific interval of time rather than applying for the complete duration.
As per my knowledge of MATLAB PDE Toolbox, the boundary conditions are usually set for the entire simulation. However, to implement time dependent boundary conditions as described, I recommend designing a function whose value changes with the simulation time.
The Neumann boundary condition can be modified by implementing a function that checks the current simulation time and decides which flux to apply. Below is one possible example of the implementation:
% Define the time-dependent Neumann boundary condition function
function bcMatrix = timeDependentBC(~, state)
if state.time <= 1e-3 % Check if the time is less than or equal to 1 ms
bcMatrix = [0, -1.34e-23]; % Apply the specified flux
else
bcMatrix = [0, 0]; % After 1 ms, set the flux to zero
end
end
% Apply the time-dependent boundary condition to Face 1
applyBoundaryCondition(model, 'neumann', 'Face', 1, 'g', @timeDependentBC, 'q', 0);
The function "timeDependentBC" retuns the appropriate boundary conditio matrix based on the current time. The "@" symbol prefixed to the function helps in creating a function handle. You may refer to this documentation to know more about function handles in MATLAB: https://in.mathworks.com/help/matlab/matlab_prog/creating-a-function-handle.html
Hope this helps.
Regards,
Nipun
0 comentarios
Ver también
Categorías
Más información sobre Boundary Conditions en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!