Discussion Closed This discussion was created more than 6 months ago and has been closed. To start a new discussion with a link back to this one, click here.

Subtracting a 2D quantity from a 1D quantity

Please login with a confirmed email address before reporting spam

I have a 2D model of the concentration of ions diffusing over time, c(t,x,y). I figured out how to calculate an average over 1 dimension, viz. y, i.e, the variable upper limit integral of c_avg(t,x,y) = 3/(y^3) ∫ c(t,x,z) z^2 dz from 0 to y (z is a dummy variable for y) by using the Coefficient Form PDE. The value of y ranges from 0 to 1.

I would like to use the value of the average where y = 1 (average concentration over the entire range of y) & subtract all values of the average from it, i.e., c_avg(t,x,1) - c_avg(t,x,y). Is there a simple way to do this?

2 Replies Last Post 19 mai 2017, 11:27 UTC−4
Lars Gregersen COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 7 years ago 19 mai 2017, 03:42 UTC−4
Hi Clyde

I'm sure that I fully understand what you are trying to do, but it should be possible to calculate the integral using projection couplings. See this section "EXAMPLES OF PROJECTION COUPLINGS" in the Reference Manual for some examples.


--
Lars Gregersen
Comsol Denmark
Hi Clyde I'm sure that I fully understand what you are trying to do, but it should be possible to calculate the integral using projection couplings. See this section "EXAMPLES OF PROJECTION COUPLINGS" in the Reference Manual for some examples. -- Lars Gregersen Comsol Denmark

Please login with a confirmed email address before reporting spam

Posted: 7 years ago 19 mai 2017, 11:27 UTC−4
Updated: 7 years ago 19 mai 2017, 13:26 UTC−4
Thanks Lars,

I had reviewed the section on Extrusion, Projection, & Scalar coupling operators; however, the examples in the Reference Manual were a bit vague. Would you know of a good resource showing a practical example?

As for what I'm working with, I have values of ion concentration over a simulated 2D contour over time, using an Extremely Fine Rectangular Mesh. The contour results in a 41 x 41 value matrix at each instance in time. To simply my scenario, let me illustrate with a 3 x 3 matrix: Let c(x,y,t) at t = tn be

| 2.4 4.5 5.1 | = | c(0,2,tn) c(1,2,tn) c(2,2,tn) |
| 1.3 3.6 1.8 | = | c(0,1,tn) c(1,1,tn) c(2,1,tn) |
| 0.7 1.2 0.3 | = | c(0,0,tn) c(1,0,tn) c(2,0,tn) |

Using Coefficient Form PDE, I can calculate the average over y as:

| 1.5 3.1 2.4 | = | <c(x,2,tn)>: this row is the mean of c(x,0,tn), c(x,1,tn), c(x,2,tn)
| 1.0 2.4 1.1 | = | <c(x,1,tn)>: this row is the mean of c(x,0,tn), c(x,1,tn)
| 0.7 1.2 0.3 | = | <c(x,0,tn)>: this row is just c(x,0,tn)

Now, I'd like to take the values of <c(x,2,tn)> copied over all rows to subtract c(x,y,tn), i.e.,

| 1.5 3.1 2.4 | - | 2.4 4.5 5.1 |
| 1.5 3.1 2.4 | - | 1.3 3.6 1.8 |
| 1.5 3.1 2.4 | - | 0.7 1.2 0.3 |

I'm thinking a Linear Extrusion would be the method to use. Would this be the best approach?
Thanks Lars, I had reviewed the section on Extrusion, Projection, & Scalar coupling operators; however, the examples in the Reference Manual were a bit vague. Would you know of a good resource showing a practical example? As for what I'm working with, I have values of ion concentration over a simulated 2D contour over time, using an Extremely Fine Rectangular Mesh. The contour results in a 41 x 41 value matrix at each instance in time. To simply my scenario, let me illustrate with a 3 x 3 matrix: Let c(x,y,t) at t = tn be | 2.4 4.5 5.1 | = | c(0,2,tn) c(1,2,tn) c(2,2,tn) | | 1.3 3.6 1.8 | = | c(0,1,tn) c(1,1,tn) c(2,1,tn) | | 0.7 1.2 0.3 | = | c(0,0,tn) c(1,0,tn) c(2,0,tn) | Using Coefficient Form PDE, I can calculate the average over y as: | 1.5 3.1 2.4 | = | : this row is the mean of c(x,0,tn), c(x,1,tn), c(x,2,tn) | 1.0 2.4 1.1 | = | : this row is the mean of c(x,0,tn), c(x,1,tn) | 0.7 1.2 0.3 | = | : this row is just c(x,0,tn) Now, I'd like to take the values of copied over all rows to subtract c(x,y,tn), i.e., | 1.5 3.1 2.4 | - | 2.4 4.5 5.1 | | 1.5 3.1 2.4 | - | 1.3 3.6 1.8 | | 1.5 3.1 2.4 | - | 0.7 1.2 0.3 | I'm thinking a Linear Extrusion would be the method to use. Would this be the best approach?

Note that while COMSOL employees may participate in the discussion forum, COMSOL® software users who are on-subscription should submit their questions via the Support Center for a more comprehensive response from the Technical Support team.