Thursday, May 23, 2013

Modeling & Simulation of Chemical Reaction | Continuous System Simulation | C++ Implementation

Chemical reactions exhibit dynamic equilibrium, which means that a combination reaction is also accomplished by the reverse process of decomposition reaction. At the steady state the rates of the forward and the backward reaction is same.

In addition to the forward reaction where Ch1 and Ch2 react to produce Ch3, there may also be backward reaction, where by, Ch3 decomposes back into Ch1 and Ch2. Let the rate of formation of Ch3 be proportional to the product of the amounts Ch1 and Ch2 present in the mixture and let the rate of decomposition of Ch3 be proportional to its amount in the mixture. 
Let us consider C1, C2  and C3 Amount of Ch1, Ch2 and Ch3 at any instant of time t, the rate of increase of C1, C2& C3 are given by the following differential equations:

dC1/dt = K1C3– K1C1C2
dC2/dt = K2C3– K1C1C2
dC3/dt=2K1C1C2-2K2C3

Where K1and K2 are constants.


As soon as the chemicals Ch1 and Ch2are mixed, the reaction starts and the amount of C1, C2, C3 in the mixture goes on changing as time progresses.The simulation of reaction will determine the state of the system. i.e. value of quantities C1, C2 and C3at different points in time. Starting at zero time, a very small increment of time is taken in each step. It is assumed to be so small, that all changes in the mixture can be taken to occur at theend of each increment. If C1(t), C2(t) and C3(t) are the quantities to there chemicals at time t, then at time t +  Δt, the quantities are ;
C1(t +  Δt) = C1(t) + dC1(t)/dt
C2(t +  Δt) = C2(t) + dC2(t)/dt
C3(t + Δt) = C3(t) + dC3(t)/d

After forming the the mathematical model, we can simulate the system using following program written in C++:
// Simulate Chemical Reaction,  +Jivan Nepali  
 #include<iostream>  
 #include<fstream>  
 using namespace std;  
 float k1 = 0.008,k2 = 0.002,del_t = 0.1;  
 float calc_c1(float c1, float c2, float c3)  
 {  
   return (c1+(k2*c3-k1*c1*c2)*del_t);  
 }  
 float calc_c2(float c1, float c2, float c3)  
 {  
   return (c2+(k2*c3-k1*c1*c2)*del_t);  
 }  
 float calc_c3(float c1, float c2, float c3)  
 {  
   return (c3+(2*k1*c1*c2-2*k2*c3)*del_t);  
 }  
 int main()  
 {  
   float c1 = 25,c2 = 80, c3 =0;  
   int i;  
   float temp_c1,temp_c2,temp_c3;  
   ofstream outfile("simulation_lab.txt");  
   outfile<<c1<<","<<c2<<","<<c3<<"\n";  
   for(i=1;i<400;i++)  
   {  
     temp_c1 = calc_c1(c1,c2,c3);  
     temp_c2 = calc_c2(c1,c2,c3);  
     temp_c3 = calc_c3(c1,c2,c3);  
     c1 = temp_c1;  
     c2 = temp_c2;  
     c3 = temp_c3;  
     outfile<<c1<<","<<c2<<","<<c3<<"\n";  
   }  
   outfile.close();  
   cout<<"\nAll data printed on the file \"Simulation_Lab.txt\" on your project folder.\n";  
   cout<<"\nHave a look!!!\n\n";  
   return 0;  
 }  
To simulate the result obtained through the above model, we can use following MATLAB code:


%Simulate Chemical Reaction, +Jivan Nepali  
data = load('simulation_lab.txt');  
 plot(data(:,1),'b-');  
 hold on;  
 plot(data(:,2),'r-');  
 hold on;  
 plot(data(:,3),'k-');  
 legend('reactant c1','reactant c2','product c3');  

The graph obtained using the MATLAB will be as shown:



Enjoy Simulating....!!!

38 comments :

  1. Be that as it may, there were a few providers who were assaulted by the DEA; the first to be struck was JLF Primary Materials.Research chemicals

    ReplyDelete
  2. While taking care of and capacity of chemicals ought to be finished with mind, the recognition of precautionary measures when blending distinctive substances is significantly all the more convincing. https://topas.com

    ReplyDelete
  3. Extremely pleasant article, I appreciated perusing your post, exceptionally decent share, I need to twit this to my adherents. Much appreciated!.  Contact us

    ReplyDelete
  4. The writer is enthusiastic about purchasing wooden furniture on the web and his exploration about best wooden furniture has brought about the arrangement of this article. 4-cl-pvp

    ReplyDelete
  5. Spot on with this write-up, I must say i believe this excellent website needs much more consideration. I’ll probably be once again to learn a great deal more, many thanks that information buy am-2201 powder online

    ReplyDelete
  6. Thanks For sharing this Superb article.I use this Article to show my assignment in college.it is useful For me Great Work. mephedrone for sale uk

    ReplyDelete
  7. About. We are one of the leading pharmacies which offer high-quality products at minimal prices. Explore our category of products today by visiting our website buy rivotril online

    ReplyDelete
  8. RS DYNAMICS supports security across many markets - national and homeland security, critical infrastructure, event management, medtech and ecological tasks.
    explosive trace detector parts
    trace explosive detector
    Trace Detection
    Faster security screening
    security screening

    ReplyDelete
  9. Its my great pleasure to visit your blog and to enjoy your great posts here. I like it a lot. I can feel that you paid much attention for those articles, as all of them make sense and are very useful.  préstamos privados

    ReplyDelete
  10. Stickers2go is the UK’s no 1 manufacturer of custom stickers printing and printed labels Order custom stickers and labels, in ANY shape and size, powered sticker printing for industry-leading quality. Order now to get discount on bespoke stickers printing

    ReplyDelete
  11. The Packaging papa are as extraordinary as they are unique and work wonders for businesses Packaging PAPA is aiming at creating boxes from extremely biodegradable material. They taking small stores to local domination, to national level brands to multi-national organization.

    ReplyDelete
  12. Quality Packaging Solutions, the name itself is self-evident of our quick and efficient services. We at Quality Packaging Solutions offer a wide variety of customized packaging options to our customers. You can get your custom cigar boxes at Quality Packaging Solutions in a cost-effective manner. We specialize in retail as well as wholesale Custom Packag

    ReplyDelete
  13. You can get your Custom Cannabis Boxes at Quality Packaging Solutions in a cost-effective manner.Qualitypackagingsolutions.co.uk offers FREE shipping around the globe. Our standard turnaround is 10-12 Business Days with FREE shipping. We also offer Rush Services with 6-8 Business Days plan where up to 25% expedite may be applicable.

    ReplyDelete
  14. The custom boxes are as extraordinary as they are unique and work wonders for businesses Packaging boxes is aiming at creating boxes from extremely biodegradable material.micro electronic blue print box They're taking small stores to local domination, to national level brands to multi-national organization.Marijuana soap boxes

    ReplyDelete
  15. Custom boxes is the U.S manufacturer of and printed labels Order custom boxes and labels, in ANY shape and size, powered printing for industry-leading quality. Custom Packaging Boxes With Logo Plus there's free delivery after you order, and our guarantee to beat any like-for-like quote for printed boxes and labels.

    ReplyDelete
  16. Individuals who are influenced by MCS as a rule have encountered harmful measures of substances through rehashed openness to engineered chemicals. tadalafil powder

    ReplyDelete
  17. This comment has been removed by the author.

    ReplyDelete
  18. This comment has been removed by the author.

    ReplyDelete
  19. Your article is very beneficial for us.If you are looking for new boxes like vape subscription box then you can visit our websiteQuality Packaging Solution .Our boxes have good quality and you can order our boxes for packing your products.

    ReplyDelete

  20. Your subject is very helpful for us.If you are looking for great quality boxes like rectangle gift boxes with Lids. you can visit our website for your Custom Boxes Printing. Our boxes have their name in the world. You can order them for packing your beautiful products.

    ReplyDelete
  21. Thank you for helping out, wonderful info. “A man will fight harder for his interests than for his rights.”custom boxes custom boxes

    ReplyDelete
  22. I was reading your article and wondered if you had considered creating an ebook on this subject. Your writing would sell it fast. You have a lot of writing talent. Research Chemicals

    ReplyDelete
  23. Thanks for taking the time to discuss this, I feel strongly about it and love learning more on this topic. If possible, as you gain expertise, would you mind updating your blog with more information? It is extremely helpful for me. kigtropin for sale

    ReplyDelete
  24. It is very informative post thanks for sharing the information.
    printed E Liquid boxes
    Cream boxes Arizona

    ReplyDelete
  25. Pychedelic High is a safe secure and discrete place where you can buy Psychedelics Like , LSD, DMT, MDMA and MUSHROOMS safely online and hassle free.
    Reviews of mdma pill.

    Best place to get buy golden teacher mushrooms.

    How to order psilocybe utopia spores?

    Where to get cheap penis envy cubensis?

    Are you looking dmt powder?

    ReplyDelete
  26. skypsychedelic.com is one of the best psychedelics company that ship to all states within 24 hours an also ships 3-6 days internationally.
    skypsychedelics produces the most quality psychedelic products such as LSD, DMT,AYAHAUSCA,MUSHROOM,
    KETAMINE.So you can click on the link below to place your order.

    ReplyDelete
  27. Hi Admin! Whether it is Chemistry, Physics or Biology every subject demands little knowledge of computer programming when it comes to simulation studies and research. Computational chemistry and process systems engineering play a major role in providing a new understanding and development of computational procedures for the simulation, design, and operation of systems ranging from atoms and molecules to industrial-scale processes. The bottom line is that learning computer programming is an invaluable skill in learning Chemistry for chemistry students, as it empowers them to do more with collected data and, ultimately, to be more efficient and effective chemical engineers and scientists. Thanks for sharing such a valuable post.

    ReplyDelete
  28. Thanks for sharing a piece of knowledgeable information with us, I got some valuable information in your article. It was awesome to read it. keep sharing great content with us.
    personalised desk calendar

    ReplyDelete
  29. You there, this is really good post here. Thanks for taking the time to post such valuable information. Quality content is what always gets the visitors coming. what is ssd solution

    ReplyDelete
  30. I really appreciate your efforts and material. I like the accommodating data you give in your articles. I'll bookmark your blog and check again here oftentimes. I am very certain I'll gain proficiency with a great deal of new stuff here! Good luck for the following.bottle necker cardboard | bottle necker cardboard

    ReplyDelete
  31. Get an opportunity to spend the night in Dubai's desert. It is an ideal escape from urban life because you will stay the evening in a vast desert camp underneath the blanket of stars. The safari trip continues with an exciting desert bashing drive and follows a variety of fun things.
    As the sun goes down, relax in the desert camp, which has a Bedouin feel to it, or relax by the flames until we represent you with a tasty BBQ meal with a delightful selection of salads and appetizers.Before actually leaving the Desert, you can enjoy the fantastic desert sun come up while eating your delicious breakfast. After an evening of dune bashing, camel riding, and significant photo shoots in the middle of a desert, a nightly camp in traditional Arab shelters in the wonderful desert, Abu Dhabi. Afterward, go to the camel farm for some fun. Stay in a traditional Arab camp with cushions and rugs, advanced lighting, and different men's and women's settings. Overnight desert safari

    ReplyDelete
  32. how do i simulate the result data on ms excel

    ReplyDelete
  33. Acknowledges for paper such a beneficial composition, I stumbled beside your blog besides decipher a limited announce. I want your technique of inscription... my garant by

    ReplyDelete
  34. packing and moving services, packing and shipping companiesto custom crating and palletizing services, our attention to detail and professionalism has set us apart from our competitors.

    ReplyDelete
  35. The content seamlessly blends educational value with engaging storytelling, making each piece a captivating learning experience.

    statuario marble

    ReplyDelete

Related Posts Plugin for WordPress, Blogger...