Answered step by step
Verified Expert Solution
Question
1 Approved Answer
C Programming Assignment - Solving a system of partial differential equation using matricies. Please try to solve the equations so that the matrixs can be
C Programming Assignment - Solving a system of partial differential equation using matricies. Please try to solve the equations so that the matrixs can be programmed in C. An example of the code I will be using to solve the matrix problem is here: https://pastebin.com/xqHUe5Wc After this question is solved I will ask to do the program also. Thank you very much for the help!
Your job is to determine the late-time concentration profile of two molecules inside a narrow chromatography column. Molecule A is added to the column with a certain rate and deposition profile, and is swept through the column by a background flow of solvent, and also undergoes diffusion. Molecule A gradually decays to molecule B, which obeys the same advection-diffusion law as molecule A. As usual, feel free to ignore the physics (or chemistry) of what is going on your job is to solve solve differential equations using a computer Overall, the reaction-diffusion equations are and where t is time, a is the spatial variable along the column, k(z) is the diffusion rate, u is the advection rate, is the decay rate, and S(x) is the source rate. We will be looking for the late-time, steady state solution to these equations The diffusion rate and source rate may be assumed to be smooth and non- negative. We will also assume v is non-negative The r domain is a E [0, L]. Boundary conditions for A and B are mixed at r 0, representing zero influx r-0 At x = L the boundary condition will be A = B = 0 You are required to use the LAPACK library to invert matrices, so the com piler flags are different this time. This library is installed on the lab computers and on daisy. Some instructions are given for installing it on a linux system on the course website; if you aren't used to compiling/installing libraries on your own system, it might be quicker just to log in to daisy. Let us say your code file is named 'prog3.c' (if not, change the filename in the compile line). The code must compile and generate no warnings when compiled with gcc -Wal1-std-c99 -g -L/home/phskak/Code/BLAS/ -L/home/phskak/Code/lapack-3.5.0/ -I/home/phskak/Code/lapack-3.5.0/1apacke/include/ prog3.c -1lapacke -llapack 1blas -lgfortran -Im Be careful copying and pasting this command line: a script containing the compiler command is also on the website (for example if you add or remove spaces then this may prevent compilation). Please call the LAPACKE C inter face and not LAPACK directly (because these are FORTRAN functions and the interface is not guaranteed to work the same way when compiled on different machines) The lab computers require different libraries (the OS and hardware are dif- ferent gcc -g band utility.c -I/usr/include/lapacke -std-c99 -Wall-llapacke -llapack -lblas -lgfortran lm and this script is also on the moodle website next to the example. Note that you may also use the 'nenneke' unix machine to compile on as well as daisy: this has valgrind installed. You will need a CSC account: instructions are on the moodle page As before, you should test your code with simple testcases. I will, again, be marking it mostly based on how well it reproduces certain tests 1 Some Suggestions . The easiest way to call LAPACK is to use the matrix example codes on the PX390 website as a 'skeleton': this provides a framework for setting the values of the matrix at particular locations and solving the inverse problem. . One way to check that your answer is right is to write a time-evolution code . There are analytical solutions to these equations for simple cases 2. N: number of grid points 3. v: advection velocity 4. T: decay rate I will leave you to determine whether these should be read as integers or floating point numbers based on their meaning (note that the example input file does not necessarily have decimal points on all the values that should be floating point). It is sufficient to use scanf to read in these parameters and simply test that the reads were successful: I am not specifically forbidding the use of other ways of reading input but I found roughly 50% of students attempting a more complicated input scheme got it wrong The functions k() and S() (in that order) will be given at the N grid points as two columns of double precision numbers in a file called 'coefficients.txt'. There is an example input parameters file and coefficents file on the assign- ment page. 4 Output: The code should the displacement w() to a file 'output.txt', , A(), B() in three column format for the grid points zo,21, rN Your job is to determine the late-time concentration profile of two molecules inside a narrow chromatography column. Molecule A is added to the column with a certain rate and deposition profile, and is swept through the column by a background flow of solvent, and also undergoes diffusion. Molecule A gradually decays to molecule B, which obeys the same advection-diffusion law as molecule A. As usual, feel free to ignore the physics (or chemistry) of what is going on your job is to solve solve differential equations using a computer Overall, the reaction-diffusion equations are and where t is time, a is the spatial variable along the column, k(z) is the diffusion rate, u is the advection rate, is the decay rate, and S(x) is the source rate. We will be looking for the late-time, steady state solution to these equations The diffusion rate and source rate may be assumed to be smooth and non- negative. We will also assume v is non-negative The r domain is a E [0, L]. Boundary conditions for A and B are mixed at r 0, representing zero influx r-0 At x = L the boundary condition will be A = B = 0 You are required to use the LAPACK library to invert matrices, so the com piler flags are different this time. This library is installed on the lab computers and on daisy. Some instructions are given for installing it on a linux system on the course website; if you aren't used to compiling/installing libraries on your own system, it might be quicker just to log in to daisy. Let us say your code file is named 'prog3.c' (if not, change the filename in the compile line). The code must compile and generate no warnings when compiled with gcc -Wal1-std-c99 -g -L/home/phskak/Code/BLAS/ -L/home/phskak/Code/lapack-3.5.0/ -I/home/phskak/Code/lapack-3.5.0/1apacke/include/ prog3.c -1lapacke -llapack 1blas -lgfortran -Im Be careful copying and pasting this command line: a script containing the compiler command is also on the website (for example if you add or remove spaces then this may prevent compilation). Please call the LAPACKE C inter face and not LAPACK directly (because these are FORTRAN functions and the interface is not guaranteed to work the same way when compiled on different machines) The lab computers require different libraries (the OS and hardware are dif- ferent gcc -g band utility.c -I/usr/include/lapacke -std-c99 -Wall-llapacke -llapack -lblas -lgfortran lm and this script is also on the moodle website next to the example. Note that you may also use the 'nenneke' unix machine to compile on as well as daisy: this has valgrind installed. You will need a CSC account: instructions are on the moodle page As before, you should test your code with simple testcases. I will, again, be marking it mostly based on how well it reproduces certain tests 1 Some Suggestions . The easiest way to call LAPACK is to use the matrix example codes on the PX390 website as a 'skeleton': this provides a framework for setting the values of the matrix at particular locations and solving the inverse problem. . One way to check that your answer is right is to write a time-evolution code . There are analytical solutions to these equations for simple cases 2. N: number of grid points 3. v: advection velocity 4. T: decay rate I will leave you to determine whether these should be read as integers or floating point numbers based on their meaning (note that the example input file does not necessarily have decimal points on all the values that should be floating point). It is sufficient to use scanf to read in these parameters and simply test that the reads were successful: I am not specifically forbidding the use of other ways of reading input but I found roughly 50% of students attempting a more complicated input scheme got it wrong The functions k() and S() (in that order) will be given at the N grid points as two columns of double precision numbers in a file called 'coefficients.txt'. There is an example input parameters file and coefficents file on the assign- ment page. 4 Output: The code should the displacement w() to a file 'output.txt', , A(), B() in three column format for the grid points zo,21, rNStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started