Passer au contenu principal
SciNet
  • Accueil
  • Tous les cours
  • Calendrier
  • Certificats
  • SciNet
    Site principal Documentation my.SciNet
  • CCDB
  • Plus
Fermer
Activer/désactiver la saisie de recherche
Français
English Français
Vous êtes connecté anonymement
Connexion
SciNet
Accueil Tous les cours Calendrier Certificats SciNet Replier Déplier
Site principal Documentation my.SciNet
CCDB
Tout déplier Tout replier
  1. Tableau de bord
  2. PHY1610 - Winter 2024
  3. Assignment 5: Laplace solver

Assignment 5: Laplace solver

Conditions d’achèvement
Ouvert le : vendredi 16 février 2024, 00:00
À rendre : vendredi 1 mars 2024, 23:59

For this assignment, you should write a modular code that solves the two-dimensional Laplace equation

$$\frac{\partial^2V}{\partial x^2} + \frac{\partial^2V}{\partial y^2} = 0$$

for the field V in a domain consisting of the area between an outer square [-1,1]×[-1,1] and an inner square [-0.1, 0.1]×[-0 1, 0.1] .  The boundary conditions are V=0 on the outer square and V=1 on the inner square.

Domain between two squares

A physical realization of this would be the electric potential inside a square coaxial cable 

Elliptical PDEs such as this one are often solved numerically using an iterative approach.  After discretizing the domain as an N x N matrix (of which are internal submatrix here is filled with 1s), at each step, each interior element is replaced by the average of  its direct neigbours in all directions, i.e.

$$V_{i,j} \leftarrow (V_{i,j+1}+V_{i,j-1}+V_{i+1,j}+V_{i-1,j})/4$$

This should be repeated for all points until convergence, I.e  until the maximum change in the new and old value of all \(V_{ij}\) is less than a given threshold.  At each iteration, the boundary conditions must be imposed.

By the way, this update rule is that of the diffusion equation with the maximal time step that is still stable.

Your program should take the number N and the threshold as command line arguments,  solve the problem using rarrays, and write the result to a file. It should be modular in much the same way as the modular gameof1d:  

  • one initialization module with header file (you can start with an array of all zeros for the interior points);
  • one iteration module with header file;
  • one output module with header file;
  • and a main program to drive the whole computation.

You do not have to create tests for this assignment, but your Makefile should have a 'run' target that performs the calculation with N=500 and epsilon=1e-6.

As always, use best practicse like makefiles, version control and commenting your code. 

Submit your repo as a zip file in the usual way by March 1 2024.

Contacter l’assistance du site
Vous êtes connecté anonymement (Connexion)
Résumé de conservation de données


All content on this website is made available under the Creative Commons Attribution 4.0 International licence, with the exception of all videos which are released under the Creative Commons Attribution-NoDerivatives 4.0 International licence.
Fourni par Moodle