1

私は、次の境界条件で MATLAB の中心差分近似を使用して、2D (x, y, t) 数値で波動方程式を解くことに関係するプロジェクトに取り組んでいます。

プロット

一般的な組み立て式は次のとおりです。

FD式

次のようないくつかの境界条件 (BC) を理解しています。

j=mでdu/dy=0、

紀元前

しかし、MATLAB でこれらの境界条件を実装する方法がわかりません。

友人が私にこれらの方程式を教えてくれました:

式

これが MATLAB コードでの私の試みですが、
これ以上先に進むことができません。

% The wave function
% Explicit 

% Universal boundary conditions for all 3 cases:
% u=0 at t=0
% du/dt=0 at t=0

% Case 1 boundary conditions
% At x=0, u=2sin(2*pi*t/5);
% At y=0, du/dy=0;
% At y=2, du/dy=0;
% At x=5, du/dx=0;
% u=0 and du/dt=0 at t=0;
%-------------------------------------------------------------------------%


% Setting up
clc; clear all; close all;

% length, time, height
L = 5; % [m]
h = 2; % [m]
T = 10; % [s]

% Constants
c_x = 1; % arbitrary 
c_y = 1; % arbitrary

dx = 0.1; % <x> increment
dy = 0.1; % <y> increment
dt = 0.1; % time increment
nx = L/dx + 1; % number of <x> samples
ny = h/dy + 1; % number of <y> samples
nt = T/dt + 1; % number of time samples
t(:,1) = linspace(0, T, nt); 

theta_x = c_x*(dt^2)/(dx^2); 
theta_y = c_y*(dt^2)/(dy^2); 
% theta_x = theta_y
theta = theta_x;
%-------------------------------------------------------------------------%

% The matrix 
U = zeros(nt, nx, ny);

% Setting up the <U> matrix with the boundary conditions - case 1
U(1, :, :) = 0; % U=0 at t=0

for tt=1:nt   % U=2sin(2pi/5*t) at x=0
    for jj=1:ny
        U(tt, 1, jj)=2*sin(2*pi/5.*t(tt));
    end 
end


for it=2:t
    for ix=2:nx-1
        for iy=2:ny-1
            % Boundary conditions

            % General case (internal):
            U1 = -U(it-1, ix, iy);
            U2 = 2*(1-2*theta)*u(it, ix, iy);
            U3 = theta*U(it, ix-1, iy);
            U4 = theta*U(it, ix+1, iy);
            U5 = theta*U(it, ix, iy-1);
            U6 = theta*U(it, ix, iy+1);



        end 
    end 
end 
4

1 に答える 1