## 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....!!!

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

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

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

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

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

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

8. Buying medicine over the Internet can make life a lot easier. Medicines on the Internet are sometimes cheaper. Your pills are delivered to your door.
buy pain medication online without prescription
buy pain relief online without prescription

9. 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

10. 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

11. 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

12. 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

13. 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.

14. 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

15. 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.

16. 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

17. 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.

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

19. This comment has been removed by the author.

20. This comment has been removed by the author.

21. our Post is very informative. If you are looking for the new CBD Sample Boxes then you must get to our company site Custom Boxes Printing and check out new box styles to pack your products in them.

22. 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.

23. 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.

24. Every business has Packaging needs, and we are specialists in knowing your custom boxes printing needs. We produce Custom Printing Services, Custom Boxes and additionally carefully make them fill your company a twofold need of Custom Printing Services co. UK and furthermore developing your things.custom packaging uk custom packaging uk

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

26. bespoke packaging boxes At Bespoke Packaging UK we strongly believe in the interests of bespoke packaging, which has multiple benefits. Over the last few decades, we have built up vast experience in producing bespoke packaging for a vast range of items.

27. bespoke packaging boxes At Bespoke Packaging UK we strongly believe in the interests of bespoke packaging, which has multiple benefits.

28. 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

29. 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

30. Great post I like it very much keep up the good work.
Cube packaging Hawaii
custom Cupcake packaging

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

32. 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?

33. AQLChemical Products and its staff of quiet professionals is committed to delivering the most realistic, fundamentally sound training experience possible. Reliable , prompt and fast on delivery.

5-MEO-DMT FOR SALE
4 aco dalt for sale
EPHEDRINE HCL for sale online

34. Great post I like it very much keep up the good work.
Lingerie Boxes wholesale

35. 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.

36. 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.

37. 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

38. 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

39. 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

40. Bespoke PackagingVery Easy to Order Any Quantities Any Size. There’s no job that’s too big, too small, or too complex for us to handle.Bespoke Packaging UK Bring your packaging projects to us, and we’ll respond with an enthusiastic

41. 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

42. Thank you for your post. I sincerely thank you for your post. If you are interested in purchasing our products, you can contact us through this website Custom Packaging Boxes UK.

43. Custom Packaging Boxes is one of the Best Packaging Printing Solution for Custom Boxes that fit your budget.Window Tie Packaging Boxes