Extracting mass balance terms (accumulation, flux, source/sink) in MRST for CO2 injection

24 views
Skip to first unread message

Hassan Jaberi

unread,
Oct 23, 2025, 12:10:47 AMOct 23
to MRST-users: The Matlab Reservoir Simulation Toolbox User Group

Hi everyone,

First of all, I am very new to MRST and any guidance would be highly appreciated. 

I’m trying to get the mass balance equation terms (accumulation, flux, and source/sink) in  MRST simulations for a CO2 injection problem.

Are there specific keywords, variables, or internal fields in MRST that correspond to these terms? 


Kind regards,
Hassan

Odd Andersen

unread,
Oct 27, 2025, 3:55:11 AMOct 27
to Hassan Jaberi, MRST-users: The Matlab Reservoir Simulation Toolbox User Group
Dear Hassan,

Thank you for getting in touch.  Before trying to answer your question, could you clarify what simulator you are using: one of the general ones (e.g. blackoil or compositional) found in the autodiff-folder, or the vertical equilibrium simulator found in the co2lab module?  

Best regards,
Odd A.

Odd Andersen
Senior Research Scientist
SINTEF Digital, Mathematics and Cybernetics
Oslo, Norway

Fra: sinte...@googlegroups.com <sinte...@googlegroups.com> på vegne av Hassan Jaberi <hasan.j...@gmail.com>
Sendt: torsdag 23. oktober 2025 00:40
Til: MRST-users: The Matlab Reservoir Simulation Toolbox User Group <sinte...@googlegroups.com>
Emne: [MRST Users] Extracting mass balance terms (accumulation, flux, source/sink) in MRST for CO2 injection
 
--
You received this message because you are subscribed to the Google Groups "MRST-users: The Matlab Reservoir Simulation Toolbox User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sintef-mrst...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/sintef-mrst/7f0a4237-a1b1-4632-822b-b0cf6dfd04f7n%40googlegroups.com.

Hassan Jaberi

unread,
Oct 27, 2025, 1:50:22 PMOct 27
to Odd Andersen, MRST-users: The Matlab Reservoir Simulation Toolbox User Group
Dear Odd,

Thank you so much for your email. I am interested to extract those terms for each grid cell in a CO2 example and I have been trying the examples in co2lab so far. 

Kind regards,
Hassan

Odd Andersen

unread,
Oct 28, 2025, 4:34:12 AMOct 28
to Hassan Jaberi, MRST-users: The Matlab Reservoir Simulation Toolbox User Group
Dear Hassan,

If I understand it correctly, you are using CO2VEBlackOilModel then?
In that case, the system equations get assembled in the function getModelEquations (found in CO2VEBlackOilTypeModel.m).  

The call inside that function to model.FlowDiscretization.componentConservationEquations computes the bare accumulation terms (per cell) and fluxes (per face).  Subsequently, sources and sinks are added inside the function, as well as special treatments for dissolution and hysteresis.  

Does this answer your question, or did you have something else in mind?

Best regards,
Odd

Odd Andersen
Senior Research Scientist
SINTEF Digital, Mathematics and Cybernetics
Oslo, Norway

Fra: Odd Andersen <Odd.An...@sintef.no>
Sendt: mandag 27. oktober 2025 08:55
Til: Hassan Jaberi <hasan.j...@gmail.com>; MRST-users: The Matlab Reservoir Simulation Toolbox User Group <sinte...@googlegroups.com>
Emne: Sv: [MRST Users] Extracting mass balance terms (accumulation, flux, source/sink) in MRST for CO2 injection
 

Hassan Jaberi

unread,
Oct 31, 2025, 1:31:50 PMOct 31
to Odd Andersen, MRST-users: The Matlab Reservoir Simulation Toolbox User Group
Hi Odd,

Thank you so much for your response. It was very helpful. I have another question. During looking at different examples, I realized that the model creation for them is different and because of that those functions that you mentioned for going straight to where mass balance terms are defined are also different. How can I find these functions in different examples? 
Also, I need to create a much simpler example to see clearly what the dimensions are and make sure the terms that I get come from the related cells with the same dimensions. How can I create the model while the model creations are different?

All the best,
Hassan 

Odd Andersen

unread,
Nov 2, 2025, 6:58:19 AMNov 2
to Hassan Jaberi, MRST-users: The Matlab Reservoir Simulation Toolbox User Group
Dear Hassan,

I'm glad if I could help.  As for your new question, it's not quite quite clear to me what you are asking about.  Perhaps you could point out the specific examples, and the difference you refer to regarding mass balance?

Best regards,
Odd 

Odd Andersen
Senior Research Scientist
SINTEF Digital, Mathematics and Cybernetics
Oslo, Norway

Fra: Hassan Jaberi <hasan.j...@gmail.com>
Sendt: fredag 31. oktober 2025 17:49
Til: Odd Andersen <Odd.An...@sintef.no>
Kopi: MRST-users: The Matlab Reservoir Simulation Toolbox User Group <sinte...@googlegroups.com>
Emne: Re: [MRST Users] Extracting mass balance terms (accumulation, flux, source/sink) in MRST for CO2 injection
 

Hassan Jaberi

unread,
Nov 10, 2025, 1:21:19 AMNov 10
to Odd Andersen, MRST-users: The Matlab Reservoir Simulation Toolbox User Group
Dear Odd, 

Thank you for your response. I figured out what I asked in the previous email. But there are some other things that I am confused about. You told me that the call inside that function to model.FlowDiscretization.componentConservationEquations computes the bare accumulation terms (per cell) and fluxes (per face). As you can see attached, I only added three lines inside this function in order to be able to extract those terms and see them in the workspace. But I am not sure if this is true since the size of the term flus shown as FLUX in the workspace is 2*1 cell and each cell has val 1540*1 double and jac 1*6 cell. But the size of flux in state.flux is 1660*2 double for each timestep in the simulation. 


Can you please let me know where the final values for accumulation, flux, source and sink are stored and how I can extract them? 

Attached you can see the screenshots related to my explanation above. I also somehow tried to simplify the Johansen example for myself and made the simulation attached based on ExampleVEJohansen. I was hoping to see how the terms are related to the simplified geometry that I used in this example by defining a simple grid, but unfortunately I couldn't. 

Thank you. 

All the best,
Hassan
simpleCO2.m
Screenshot 2025-11-09 220657.png
Screenshot 2025-11-09 220141.png
Screenshot 2025-11-09 220941.png
Screenshot 2025-11-09 220754.png
Reply all
Reply to author
Forward
0 new messages