# Tag Info

## Hot answers tagged boundary-conditions

5

The short answer is that you need $$\phi_{-1} = \phi_0$$ $$\phi_N = \phi_{N-1}$$ to impose $\nabla\phi=0$. A quick check by making the following change if idx == -1: idx = 0 elif idx == N: idx = N-1 in the code, you have posted shows that the average $\phi$ remains constant up to 14 decimal places. To see why this is the correct boundary condition ...

4

You're approaching this the wrong way by using the product rule of differentiation. Rather, making use of the fact that $$\frac{\partial u(x_i)}{\partial x} \approx \frac{u_{i+1/2}-u_{i-1/2}}{\Delta x},$$ the first step in finding what you need to do is to recognize that $$z(x_i)\frac{\partial u(x_i)}{\partial x} \approx z_i \frac{u_{i+1/2}-u_{i-1/2}... 3 You could use a discretization method such as the finite element or finite difference method with a linearization technique such as Picard or Newton method to solve this problem. A similar question is this. The main idea of these solution techniques is as follows: Pick an initial guess for the solution. Linearize your equation and write an updated solution ... 3 Expanding (sort of) on @MPIchael's answer, you can pick any smooth function you like and plug it into the heat equation to give a problem to then work the other way. In numerical methods, we call this the Method of Manufactured Solutions, and it is used extensively for verifying computer programs designed to simulate PDEs. You'll have to add a forcing ... 2 Are you sure that you have the correct boundary conditions? I think the equation you state for the analytical case,$$H=x/\tanh(x)-1$$is incompatible with the boundary condition H(\bar{\epsilon})=\bar{\epsilon} where \bar{\epsilon} is large. Maybe this is why you are getting incorrect behaviour for large x? I tried solving your equation for the \... 2 It depends on the equation you are solving. For example, consider the following heat equation with a source term:$$ \frac{dT}{dt} - \nabla^2 T = S$$If S \neq 0, then you have a source term that changes the value of the temperature as time evolves. Consequently, even if your initial condition is T(\textbf{x},t)=0, your temperature will increase because ... 2 As David said, absorbing boundary conditions won't be completely reflectionless. That said, we can reduce relfections quite a bit, which helps to avoid influence from the boundaries while the particle still travelling inside. Since this is a time dependent problem, one simple choice of boundary conditions will look like this. At the left boundary:$$\frac{\...

2

TL DR: $$u_1(x_1) = \cos(2\pi~(\frac{x_1}{L_1}) - \pi) + 1$$ $$u_2(x_2) = \cos(2\pi~(\frac{x_2}{L_2}) - \pi) + 1$$ $$u(x,t) = \exp(-a t) u_1(x_1) u_2(x_1)$$ How to construct it: Sines and cosines are easily differentiable so they make a good starting point to construct such a solution. We chose a section and offset of the cosine which has a derivative of ...

2

Bill Greene presents the point of view of how things have been done traditionally. The "modern" way is to add "constraints" to your linear system which, in the current case, would be $$u_{3x} = -u_{3y}.$$ These constraints can be entered straight into the linear system without the detour of the augmented linear system you show -- ...

2

The traditional way to handle this type of boundary condition is to create a transformed coordinate system at node 3 so that one of its axes is along the direction you want to constrain. You use the coordinate transformation matrix at this node to transform your stiffness matrix and then constrain the system in the usual way, e.g. by removing the equation ...

2

Let's take the example of the unsteady one-dimensional heat equation inside a solid on a domain $x\in[0,1]$: $$\partial_t u - D\partial_{xx} u = 0$$ with the initial profil $u(0,x) = u_0(x)$ at $t=0$, and Dirchlet boundary conditions enforcing that the wall at $x=0$ (respectively $x=1$) is at temperature $u_{L}$ (respectively $u_{R}$). If we use discretise ...

1

Have you plotted the solution using a visualization package or just a cut through the middle of your domain? Sometimes just looking at the solution you're generating will give you an insight into where it's arising from. Based on your description, I'd say there's a mistake in your implementation of your boundary condition. ETA: The last sentence is probably ...

1

You simply make sure that the initial condition satisfies the boundary conditions and that you don't add anything to the elements of $u_{n+1}$ corresponding to the boundary. In other words, you drop the rows and columns of $M$ that correspond to the boundary nodes and solve only in the interior nodes. Let me add that inhomogeneous Dirichlet boundary ...

1

As the mathematica.se thread shows, the solution of \begin{aligned}\frac{\partial}{\partial x}\left( \operatorname{sign}(x) u(x) \right) + \frac{\partial}{\partial x} \left( \sqrt{u(x)} \frac{\partial u}{\partial x}(x) \right) &= 0 & &\text{in } \Omega = (-6,6), \\ u &= 0 & &\text{on } \partial \Omega = \{-6,6\} \end{aligned} is ...

1

It depends on the implementation. More than the connectivity, you need to focus on the orientation of the normals. The common convention is to define the connectivity such that the normals on the boundary elements point away from the solid. This is relatively easy in 2D since there are only two nodes for one (linear) element. For 3D, choose the connectivity ...

1

It's just a linear 1D problem, you can easily do implicit time stepping here so that numerical stability would not be a problem. The accuracy should not be an issue either since for such a simple problem you should be able to use any spatial resolution you need. More specifically, let the equation be discretized in space by any scheme, e.g., low-order ...

1

I have also had this problem and spent a lot of time on various forums and I have finally come up with a good solution. This solution will allow you to specify a boundary condition on any whole subdomain within your geometry, and each subdomain can have its own separate boundary condition. I am posting this solution here as the old official Fenics QA forum ...

1

There's a really nice book by Li and Ito on the immersed interface method, which was designed to solve problems like yours. Chapter 2 describes 1D problems. Basically, the finite difference method works well when the coefficients are smooth, but when they're rapidly varying or have discontinuities things can go to hell very quickly. You can make it work by ...

1

It looks to me like you want to look at the step-62 tutorial program of deal.II, written by Daniel Garcia. It covers pretty much exactly the application you have in mind.

1

Maybe this isn't a helpful response but the reason this happens for the matrix form of Laplacians is because this actually happens for the true infinite-dimensional Laplacians in some settings. In recangular coordinates, $N$-D Laplacians act exactly like their discretized counterparts in this way. For example, let $\Delta_3$ by the Laplacian on $[0,1]^3$ ...

1

This is my attempt at providing some intuition. Everything I state might be obvious, moreover it doesn't have much to do with physics, so this could be a non-answer. I will ignore boundary conditions. Imagine we have a 2D grid with function values $u_{ij}$ for $i=1\ldots m, j=1\ldots n$. Let the $x$ axis point downward, the $y$ axis to the right. N.b. $z$ ...

Only top voted, non community-wiki answers of a minimum length are eligible