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 4: GSL Library for root finding

Assignment 4: GSL Library for root finding

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

Consider a chemical reaction between the three substances X, Y, Z in solution (well-mixed).

$$2\textrm X + Y \rightleftharpoons 2 Z$$

Let us denote the concentrations of X, Y, and Z by x, y, and z.

Let the rate of the forward reaction be \(k_1\), and that of the backward reaction be \(k_2\).

According to chemical kinetics, in equilibrium, the concentrations will satisfy

$$k_1x^2y=k_2z^2$$

But this single equation is not enough to determine the three concentrations.  

Additional information comes from the chemical reaction itself, which shows that \(x-2y\) is conserved in the reaction, and so is \(x+z\). In other words,

$$x-2y = c_1$$

$$x+z = c_2$$

Where \(c_1\) and \(c_2\) are set by the initial concentrations of the substances, denoted by \(x_0\), \(y_0\) and \(z_0\). I.e.

$$c_1=x_0-2y_0$$

$$c_2=x_0+z_0.$$

Your assignment

In this assignment, you need to solve the equilibrium values of \(x\), \(y\) and \(z\) given the following parameters and initial concentrations:

$$k_1=1, k_2=0.7, x_0 = 0.5, y_0 = 1, z_0 = 0$$

Solve numerically for the concentrations to within at least 1 part in 1e6 in two ways

  • First, directly using the above three equations, using a three-dimensional root finding routine from the GSL.
  • Second, using that one can combine the above three equations into a single one for \(x\).

I.e.

$$ k_1x^3-(c_1k_1+2k_2)x^2+4c_2k_2 x - 2k_2 c_2^2 = 0 $$

Use one of the polynomial root finding routines from the GSL for this second part.

The GSL is a C library with many components. It is already installed in the teach cluster ("module load gcc/13 gsl/2.7"). You will need to read the gsl documentation, in particular that for multidimensional root finding and for polynomial root finding.

Two separate codes for the two cases (which should print out the result for x, y, and z), and one Makefile that can build both, will suffice for this assignment. We expect several git commits and commenting. (There is no real opportunity for modularization.)

Your git repository should be commited by Wed Feb 16, 2024, at 11:55 PM. 


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