Click here for a transcript of the video.
Li Li: All right. Let's start the lesson on ion exchange. I discussed in the text that ion exchange is somewhat similar to surface complexation. But then you have multiple cations. And these cations have different affinity to the solid surface. So essentially, they are competing with each other. As one with high affinity and high concentration in the water phase, it ends up to have more on the solid phase.
So if you look at the Keq values of the different-- you can get more or less a sense of their relative affinity. But also, if one particular species has high concentration in the water, it also ends up to be more on the solid phase because it has high concentration if you write a Keq values. In order to get the Keq, you need higher corresponding solid phase concentration.
So let's look at the example. Actually, this really should be 4.1. And that's 3.1 So let's go through this example. And we'll talk about how to set it up. This example, I'm kind of thinking about Marcellus Shale water, produced water or flowback water. And you have some concentration. We know there are a lot of different cations in this type of water.
So I'm giving you a typical composition of Marcellus Shale water, with high sodium, chloride, calcium. But you also have barium, strontium. Actually, the barium, strontium concentration is relatively low in what you have here. So we are here.
And I'm giving you both PPM and mole per kilogram water. Actually both of them, you can put in directly. So it's your choice. Now, I'm saying you have 3,000 milliliter of batch reactives. And water is equivalent with partial pressure of CO2, which is this is atmospheric concentration of CO2, try to simulate condition in soil.
And then, I'm giving you this table that essentially can document the K value for each reaction process. And the question I'm asking you, the first is, without any aqueous complexation reaction. So you are not going to put-- you're still going to put OH minus, carbonate, and all that. But you are not going to put, for example, calcium chloride, calcium OH plus, and all these secondary species.
I'm asking you to see, how much is absorbed on the exchange site. And what is the percentage of the absorption on the exchange sites compared to its original total concentration. Essentially, I'm asking you to make a table for each major cation and list aqueous concentration column and list another exchange site column, and compare different species.
But also calculate the percentage of the ones that are on the exchange site. Because they all start with aqueous concentration. So comparing the absolute value sometimes does not tell a lot of things. So you need to normalize them to the original total concentration.
But then I also want you to look at, on the exchange site, how much is occupied by each of these cations? How much is sodium? How much calcium? How much is barium, strontium, et cetera. So that's the first question.
And then second question is, running the simulation with speciation or complexation reactions. List the formation of chloride species and OH minus species, all these listed here. And then I'm asking you to answer the same question. So comparing one to, essentially, you getting some information about how important are these aqueous complexation. Does aqueous complexation help or not help these cations to go on the service site?
So let's start doing this. We had a discussion today. And then you are saying, maybe you can start with a blank one. So today I'm going to start with a blank input file. Essentially, there's not much information there. Except that you will be doing like all the runtime parameters up there.
And I also put a bit of output keyword specification there. I put two spacial profile time points. So it will be running into 100 minutes. And then, initial condition, this is already specified. We will specify initial condition later.
So let's go through each agree grid block-- keyword block. First one is discretization. This one here, you essentially would specify the size. And we know it's one grid block. So you would be doing-- first of all, you need to put in the units for length.
And we talked about this is 300 milliliters. So if you want to put centimeters or meters, that's fine. Last time we put centimeters. So this time, maybe, we'll just put in meters to have some variation. So the distance unit will be meters. And then before, we always specify x zones. You essentially only have one species.
You will specify one zone. And then, because it's 300 milliliters, so that's 300 centimeters cubed. And converting to meters would be 3 times 10 to the minus 4 meters cubed. I mentioned before, this is essentially, when we do this, we specify that this is essentially the length of x zone.
But by default, you actually have y zone and z zone. And the code is going to assume in these other two directions that you don't specify, it's going to 1 meter and 1 meter. So here you have specified 0.003 meters. So essentially your volume is 0.0003 cubic meters, which is 300 milliliters.
So that's here. Now you specify, essentially, the size of your system. Now we probably can try this now, just to be sure that you are not making any mistakes taking this block. I always think it's a good practice to input one by one. And after each keyword block, you kind of check if everything is correct, you didn't make any wrong mistakes or whatever in the input file.
So the top one is read and write. But because we didn't specify any condition, it doesn't know what to do. That's OK. At least it didn't give me anything about like it's not specified correct or something like that. So let's do that again. Let's continue.
So let's specify primary species. And for that, we need to look at our table. So always put H plus first. I mentioned that before, probably multiple times. But it's worth to mention again. Always put H plus. And we know we have CO2 aq. So essentially, it follows that table. The system is with CO2 gas. So you need to put to CO2 aq. No, actually you don't need because it's just primary species.
And then you will be putting all the different species like sodium-- just calcium, potassium, magnesium, barium, strontium, and chloride. That's your primary species on the table.
But remember is that we also have kaolinite. And I mentioned that for each mineral you put-- so later on we'll put kaolinite in the mineral block. Remember that in order for it to work for the mineral you will need to look up what this mineral is made up of. So let's look through.
Let's open with Notepad. So let's search for kaolinite. Let's see what it can post up. So kaolin coming up. You have H plus, you already have. You have aluminum. You have silica, SiO2 aq H2O. So essentially it's aluminum silica. Because aluminum silicon is not there on the list, so let's put these two in so we don't get messed up.
So you would have aluminum. And then you have SiO2 aq. So these are the species we can think about it. So that's the primary species list.
Now I'm saying that we don't put any secondary species like the chloride OH species. But we still need to put OH- in. Because you can't do anything without OH-, because that's water dissociation-association. And then you also have CO2 species. So you have to have bicarbonate and carbonate species. So these are the main species that you have to complete.
So that's a secondary species. And gases, do we have gases? We do because we have the CO2 aq that is in equilibrium with gas. So you do need the CO2 gas phase. And then, you have ion exchange. So this is a new keyword block. We learned this in this unit.
So the key here is exchange, the keyword exchange. I shouldn't do it in Word. And then I'm going to give it a name, which is x representing surface species. But this one is on kaolinite. So let's do this. Let's call that. And this is on the mineral kaolinite. So essentially, you put as an exchange, you have the keyword block and name of the surface site, exchange site, and then the name of the mineral.
But also, the other thing you need to specify is what convention are you using for the calculation. We talked about three different-- like Vanselow, Gaines-Thomas for example. And let's here, let's do Vanselow. Vanselow is the one the most commonly used conventions. So that's ion exchange.
So this keyword block is somewhat new. And you need to think about, OK, doing that, your flux will be here. But again, here, you have the kaolinite. And you need to put in the mineral kaolinite there, the name there. If it's a mineral dissolution precipitation, you would need to put it in like kinetic information, for example, dissolution rates and everything. But here we are not really looking at it the dissolution precipitation kaolin. So we can just specify kaolinite.
So these are all the kind of building blocks of your system, chemistry building blocks of your system. And now we're going to specify what condition we have. And again, we're looking at the table we have. It's Table 3. So let's just copy the species from aqueous, the species we had before. And we'll copy it. And then we will add whatever concentrations they need to be.
We probably should have units first. Actually, in condition, we all need to specify units. And this will, let's say, do PPM. And we can do temperature. We must always do temperature, which is 25.0. You can specify H plus. But this table, I'm giving you 7.02. So it's easier to do just pH, which would be 7.02.
And you have CO2 aq, we discussed last time in last lesson, you can specify the CO2 concentration with gas phase in this way, when you have a specific at partial pressure of that gas. E minus 4, so that's for CO2. And then we have sodium, which is 7,900.0. Calcium, 2,774.0. And the you have potassium, 82.5.
I always think it's good to line up and make it neat and clean. Because if you're not clean and lined up and all that, it's very easy to make mistakes. It's almost like when you write code. You want to keep it very clean and organized so that minimizes the chance of making mistakes. And when you check, it's easier to see. So it's worth the effort. 6.5. And chloride, we'll be doing that with charge. So you just put the charge there.
How do I know that this is going to be positive charge without this? You can try database sweep first, if you want. But I kind of know because I know there's a lot of cations there. You see there's a lot of cations there. But there's almost the only species for now will be chloride in OH minus. And pH you know is 7. So OH would be 10 to the minus 7 or something. So it must be positive charged.
And then we don't really have much of the aluminum. But we can put, for example, let's say we did before with this small concentration, just 3%. It's there. Acidic. So these are the primary species, our total concentration of primary species.
Now I need to, so, in a beaker, that's the water phase composition. But then you also need to specify how much solids is there and how much surface area of a solid, how much CC and all of that. So let's say we have volume fraction of the kaolinite is 0.005. I think I didn't specify that in the file. Let's do that with sediment with kaolinite being the major-- with specific surface area. And then I'll add the kaolinite occupies 0.005 of the total volume.
So you can actually calculate that because you have 0.005. And then the total concentrated volume is 300 milliliters. So that means you have about 1.5 milliliter of the kaolinite. And we should specify the same thing in the input file. So leave a space line here just to have the division between the solid phase and aqueous phase.
So kaolinite, first thing you need to specify is 0.005 volume fraction. Actually, of the solid phase, all these-- So essentially, you have 0.005. So that's actually smaller. We started talking about it. We didn't really put the porosity. We actually should put a porosity there.
Let's finish this mineral for a specific surface area. We said it's 13.9 meters squared per-- so it's volume fraction first on solid phase, and then specific surface area using SSA in meters squared per gram.
So that's a mineral. But you also need to specify the surface site and exchange. So you have xkao, which is your name that's specified in the exchange. This needs to be consistent with the exchange grid block. And then you have this kaolinite CC, which specifies how much kaolinite exchange capacity you have.
Let's do a bit of calculation here. Let me just make some notes here. You have 100.0 meq per kilogram, which is essentially 100.0 eq per gram. And this is equivalent to 1.0 E minus 2 eq per 100 grams, and also equivalent to 1.0 E minus 4-- oh, I'm sorry. This is actually not right.
You have kilogram to gram. And then that's a solvent, And meq to eq is 10 to minus 3. So this is actually 1.0 E minus 4. This is essentially the same as-- let me check the units of CrunchFlow. It's eq per gram. So essentially, eq per kilogram.
So this will be actually-- we should convert to eq per kilogram. Already kilogram, so eq 100 times 10 to minus 3, which is 10 to minus 2. I'm sorry. This should be 10 to minus 1, essentially 0.1 eq per kilogram. We actually don't really need that. We can do our conversion.
Now, so that means you need to put-- because this is CrunchFlow units. So this will be essentially 0.1. So you specify the mineral volume fraction keq. But actually, OK, here I said we actually need a little bit porosity. So let's say you have-- we probably should say 99.5% is water. So you actually porosity of 9--
So actually I should put kaolinite being 100%, 1.0, meaning all the solid phase of the kaolinite, because this is saying the total volume. So the rest of it is all water. And then so your porosity is 0.995. And you have 100%. They're all on the solid phase. This is volume fraction on solid. You only have kaolinite. That's what I mean. So that's a condition.
So I guess, do we need anything else? We have the dimension. Let's just try that. Dimension, Vanselow, secondary species, primary species, and all that. So we should be OK. We don't need to do any timestamping. Let's try if it works.
So it'd be lesson 4.1.in. Specify porosity smaller than zero. Let's see. Must be somewhere, something wrong in the input file. Maybe it's error. I don't know. 0.0. Let's just try again. 4.1.in. Hm. Interesting.
A lot of times when it reports one error, a lot of times it's because something else is wrong. I wonder if this is it because I have it opened in the Word format. So let me just copy everything and open in Notepad and see if it's because of that.
And we're going to call it Lesson 4.1 again. And we specify lesson 4.1.in. OK, because I'm opening that. Let's see. Let's try it again.
I do have this just specified. OK, let's see. Hm. Because of this, I think it's still the original one. Now it's in the-- let's do this. Hm. That's very interesting.
Oh, the volume -- Let me just think about it. I might have forgotten in. It does need to be the volume fraction total. So then you can-- I just realized that.
So the original file was right. It is a total volume. It's not the solid phase. That kind of mistake was different type of information. So let's try it. I think that's a reason. Because I specified one here. And then, it was seeing porosity-- it specified that it was 1 kaolinite So it will say porosity is smaller than 1 or equal to zero essentially.
Let's try it again. I believe that is the error. Now it runs. OK, great. So you now see the process of doing this. I also make mistakes. And it takes time to debug and to realize what's wrong. And in this case, actually, what is wrong here, it is porosity. So it does point out to the right location. So the lesson here is volume fraction on total volume system.
So later on, if for example, if you have multiple minerals here, let's say you specify kaolinite, you specify calcite, another mineral. So volume fraction of the mineral and the volume function of the porosity needs to add up to be 1.0. That's what you need to remember. Or the a batch reactor.
So now we can look at the output file, essentially. Let's look at, well, two files here for each because I specified two different times. But you can imagine that they should be the same. I can tell because the ion exchange reaction occurs really fast.
It doesn't have time dimension. So it doesn't really matter if it's 100 minutes or it's 0.1 minutes. Because it reached equivalence instantaneously. So if you compare this exchange one versus exchange two, they should have the same concentration, essentially.
So you have one, two. It's the exact same. So this is the exchange output, essentially, specifying in mole per gram solid, how much sodium on the surface, how much potassium, how much calcium, magnesium, strontium.
And you can see from the list, the dominant species is sodium, and then followed by calcium. Both of these species are very high concentration in the solution. Let's look at the input file again. Let's look at the table again.
So sodium and calcium are the highest two concentrations. Potassium was relatively low. Magnesium, barium is in hundreds. And strontium has lowest concentration. So let's look at this again.
So more or less, in here, because of the huge difference in concentration, you end up the sodium has the higher concentration. Calcium has the second highest. And then you have magnesium, barium, and strontium. So magnesium is a bit higher than barium, too. So the last one is barium. So that's for the exchange site.
And then if you look at the aqueous site, let's look at total concentration. That'll give you how much is in the-- total concentration is not in log units. So you have pH. You have CO2. Sodium, sodium goes from-- actually it's-- now you think about it.
The output is all in mole per kilogram water. So it's actually probably better if you're using the input file mole per kilogram water. So you can look at the differences between the output, which is after the reaction, to before the reaction. So now you have sodium at 0.34. Potassium, this much.
And you actually can calculate, for example. So these are the concentrations. This is per kilogram water. So you know there's 300 milliliters water. So this concentration times the volume of the water, that gives you the mass in the water phase. And for the exchange site, it gives you in units of mole per kilogram per gram solid.
And you can assume that we know it's 0.005 of the total volume of kaolin. So we actually can calculate from the 300 milliliter times 0.005, which is 1.5 milliliter of kaolinite. And so it's 1.5 centimeters cubed of kaolinite. You can convert that to gram of kaolinite using the density of the kaolinite, give you the total gram of the solid phase. And that, you can convert to how much mass on the exchange site.
So with that calculation, you essentially will be able to calculate how much for each species is in water and how much is actually in the solid phase for each species, the percentage. So you know which one more, actually. So that's for aqueous phase and solid phase and all that.
So the second question for that is when you do include these aqueous complexations. Let's do that. I'm closing this, closing this. I'm going to add the secondary species, more species. So this, it would be having all the OH species and chloride species. So let's see. Let's go through the list.
You have sodium chloride, which is aq because it doesn't have charge. And then you could have NaOH aq. Let's just go through each species. And then there's sodium. You could have calcium chloride positive, calcium OH positive, then you have potassium chloride aq. And then CKOH aq, Mg, MgOH plus, BaCl plus, BaOH plus. What else? Strontium. OK. Strontium, Cl plus. Strontium OH plus.
When I input these, I always try to be very careful. And I probably mentioned that you cannot use tab in the input file. Also you cannot use comments on the middle of the line. When you need to comment, you need to start new line. Otherwise, it could get confused.
So I to be more careful when putting this input file. Because if you're not careful, you end up spending more time debugging and all of the frustration and all that. So keep things neat. And be careful when you input these. That will minimize the chance of making a mistake and that. I mentioned that before.
So then you can save that original output file to a different folder. Otherwise, because I run, it will override to the original file. Here, just for demonstration, I don't do that. So if I run it again, it will surely overwrite everything. That's fine.
Secondary species input file not find in database. Let's see what happens. Hm. We just run it and it works. So it must mean I either made some mistake or let's see. Secondary species input file not found in database. I'm pretty sure that's not true. I'm sure there is a database for CO3. I'm going to search for CO3.
It should be there. Because, otherwise the previous run wouldn't finish. So it's there. So there is nothing wrong with the database. So it must be the input file. It's almost always our fault, as you can tell. Secondary species, just make sure everything is-- hm.
Looks like there might be something wrong there because I couldn't go up. Oh, OK. So there's a lot of space there. And when it started lines, that space might be too long. So it couldn't-- OK. Let's just do it again. This is probably it, I think.
So when you do this, OK, so you have this. Try to not have too much space in between. Otherwise, the code cannot handle it if it's too long. There are certain character limits in each line that the code can process. Let's do it again. I think that's the problem.
4.1.-- Now it runs. So it runs and you can see from the date modified, it's just the right time. So that means it's all the output file updated. And if you look at the exchange again and compare to the previous one if you saved it-- so you will. When you do homework, you will need to save it and compare and see how much difference does it make.
We went through the output file. So I don't think I need to talk more. What you will need to do is in each CrunchFlow, the one without aqueous speciation, make a table for the mass fraction of each of aqueous phase and mass fraction of the solid phase on the exchange site. And then do that for each major cation.
And then, do the second question when you do have these aqueous complexation, how much difference does it make? And you can also check the specific concentration of all the aqueous species to see which one dominant and all that. And for this, if you want is all the dominant species, you don't need to open each exchange file and everything. You actually can just look at the output file, less than 4.1 output file. All the concentrations should be there.
I used the output file just for you to see what is in this output file. But in here, this part should have everything there. And this part might not give you the unit so you can actually dig into the exchange or exchange.out in this file to look if you forgot about units.
For solid, it's mole per gram. For aqueous, it's mole per kilogram water. So it'd have all the different species. It'd also have all the exchange concentration. It'd also have all the aqueous concentration there. So you have everything you need.
I'm going to stop here. And you saw me make mistakes and then we debugged it. Actually, both times the code pointed the right place that I made a mistake. The first one was porosity because I didn't put porosity right. I put high kaolinite 1.0, so there's no room for porosity.
The second one is CO3 minus minus, and there's too many blank space in front of that. So the code doesn't realize it. Anyway, so that's the two mistakes I made. Try to make it kind of no space, just do enter for each species. You'll be fine.
All right. So I'm going to stop here. And you'll be working on the homework and everything. Have fun.