0% found this document useful (0 votes)
51 views1 page

Linear Algebra Simulation in Python

This document provides instructions for a practice lab assignment on linear algebra using Python programming. Students are asked to write a Python program to solve a system of linear equations modeling a chemical mixing process using four mixers and volumetric flowrates between them. The program must use the Gauss-Jordan elimination method and be generalized to solve systems with any number of variables and equations. Students have one week to submit a single Python file with their work.

Uploaded by

SAPNA SUHAG
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
51 views1 page

Linear Algebra Simulation in Python

This document provides instructions for a practice lab assignment on linear algebra using Python programming. Students are asked to write a Python program to solve a system of linear equations modeling a chemical mixing process using four mixers and volumetric flowrates between them. The program must use the Gauss-Jordan elimination method and be generalized to solve systems with any number of variables and equations. Students have one week to submit a single Python file with their work.

Uploaded by

SAPNA SUHAG
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Design and Simulation Lab (CHCE 4111)

B. Tech Chemical Engineering Spl. Refining and Petrochemicals, Semester VII


UPES, Dehradun
AY – 2021 - 22
Dr. Nilanjana Banerjee Department of Chemical Engineering

Practice Lab – 3 Linear algebra using python programming


Instructions: Each question can be programmed as a cell. Create one single .py file and submit it
on blackboard 1 week from the date of uploading. Remember each programmer has his/her own
style of programming which is like a signature, unique. So, it becomes very apparent when you
have copied someone else’s work. You will be penalized for each copied work.

Consider the following mixing process. This is a common chemical engineering scenario which
arise when you have multiple reactors in series and/or parallel. Though in our case we are not
considering any sort of reaction happening to make the system simpler.

Here Q01, Q12, Q13, Q22, Q32, Q34, Q41, and Q44 denote the volumetric flowrates and CO1, C1,
C2, C3 and C4 denote the initial concentration and concentrations in mixer 1, 2, 3 and 4
respectively. To develop the sets of linear equations, we will have to write a mass balance
equation across each of these mixers.

Remember, as per mass balance, Mass in = Mass out. i.e. if a mass balance is written across the
first mixer then Q01*CO1 + Q41*C4 = Q12*C1 + Q13*C1. As you can see, there are 4 unknown
variables, so to make the system solvable there should be 4 sets of linear equation.

1. Develop the sets of Linear Algebraic equation.


2. Develop the logic/algorithm for the program. Draw the flowchart to describe the
algorithm.
3. Write a python function/program to solve the above sets of linear equations using
Gauss-Jordan Elimination method. Make the function generalized enough so that it
can be used for any number of variables and sets of equations. The code will be tested
for different sets of linear equations.
Page 1 of 1
NB

Common questions

Powered by AI

The principle of 'mass in equals mass out' simplifies the creation of linear equations as it provides a foundation for setting up balances in chemical systems. By equating the total mass entering and leaving each mixer, clear relationships between flow rates and concentrations can be established, resulting in straightforward linear equations that describe the system accurately .

Submitting original work in chemical engineering programming projects is important for maintaining academic integrity, ensuring personal learning and understanding, and preventing plagiarism. It highlights an individual’s ability to apply concepts correctly and innovate solutions tailored to specific engineering problems, which is vital for professional development and ethical standards .

Programming style uniqueness is significant in chemical engineering problem-solving because it reflects individual approaches to coding and problem structuring, which can impact the clarity and efficiency of the solution. Unique styles also help in distinguishing original work and mitigating intellectual property issues such as plagiarism, ensuring each solution is personalized and appropriate for the specific engineering challenge .

The potential challenges of using Gauss-Jordan Elimination for solving linear equations include numerical instability, especially for large or poorly conditioned matrices, which can lead to significant rounding errors. Additionally, the method might be computationally expensive for very large systems, impacting efficiency. These issues require careful implementation of algorithms and sometimes the use of more stable numerical methods depending on the problem's complexity .

Mass balance in chemical engineering contexts, such as multiple mixers in series or parallel, ensures that the input mass equals the output mass across a system. For instance, in a sequence of mixers, the equation Q01*CO1 + Q41*C4 = Q12*C1 + Q13*C1 represents the balance of mass for the first mixer, considering all inflows and outflows. This principle is crucial for creating solvable linear equations that represent the flow and concentration in each mixer .

To develop linear algebraic equations for a mixing system with multiple unknowns, each mixer must be analyzed for mass inflow and outflow. For instance, for mixer 1, the mass balance is Q01*CO1 + Q41*C4 = Q12*C1 + Q13*C1, which accounts for the flow rates and concentrations entering and leaving the mixer. This forms one equation in a system of equations, and similar balances must be applied to other mixers to form a comprehensive solvable system of linear equations .

To generalize a Python function to solve any number of linear equations using the Gauss-Jordan Elimination method, the function must dynamically handle matrices of varying dimensions. This involves writing code to: 1) initialize and parse the input matrix; 2) automate pivot operations to eliminate terms below the pivot; 3) apply row operations to create a diagonal matrix; and 4) integrate back-substitution to derive the solution for any number of variables. This flexibility is achieved by employing for loops and conditional checks that adjust operations based on matrix size .

Key steps in creating an algorithm and flowchart for solving linear equations include: 1) defining the problem by setting up linear mass balance equations for each mixer; 2) determining the variables and constants involved; 3) selecting an appropriate method for solving the equations, such as Gauss-Jordan elimination; 4) translating this method into an algorithm with step-by-step instructions; 5) creating a flowchart to visually represent the algorithm's logic and sequence. This process ensures a clear and organized path to a solution .

Flowcharts support the algorithm development process by providing a visual representation of the logical sequence and flow of operations, enhancing clarity and understanding. They help in identifying potential errors, optimizing steps, and ensuring all functional elements in a chemical engineering problem are addressed logically. This makes complex processes easier to follow and facilitates efficient debugging and refinement of solutions .

Testing Python code for solving linear equations involves considering numerical precision and robustness across different dataset sizes and complexities. Test cases should include singular matrices, non-square matrices, and matrices with varying conditions to evaluate the effectiveness of the algorithm. Ensuring the code handles edge cases and exceptions gracefully is crucial for reliability in diverse chemical engineering applications .

You might also like