- Thank you received: 29
DG and Newtons method linearization
6 years 9 months ago #342
by cwinters
Replied by cwinters on topic DG and Newtons method linearization
Hi,
if I understand you correct, you just want do set more complicated functions for A and Sigma?
You can use a indicator function
or any other "CoefficentFunction".
If you call
within python, you get some information what you can do with CoefficientFunctions.
Best,
Christoph
if I understand you correct, you just want do set more complicated functions for A and Sigma?
You can use a indicator function
Code:
Sigma.Set(IfPos(x-1800,x,0))
If you call
Code:
help(CoefficientFunction)
Best,
Christoph
6 years 9 months ago #343
by Matejczyk
Replied by Matejczyk on topic DG and Newtons method linearization
Thanks Christoph! I was looking for that for quite some time. I will try then to put it all together now.
Best wishes,
B
Best wishes,
B
6 years 9 months ago #355
by Matejczyk
Replied by Matejczyk on topic DG and Newtons method linearization
Dear Christoph,
I've managed to make my HDG with the Newton loop code running. As it is only a part of a bigger project I experienced some new problem. In order to use the command a.Apply where a is the bilinear form for the HDG formulation I need to increase the heap size by SetHeapSize(100000000). That works fine when I try to solve my equation once. Unfortunately, I would love to use it as a part of the som optimization problem and need to solve the equation in a loop with different parameters. When I solve the equation for the second time I encounter the problem with the heap size- the program freezes at the application of the form as it was because with the standard size of the heap. I believe I do something wrong with the memory management. I was trying to use the del and gc.collect() to free some memory but it did not help.
Any idea what might be the issue?
Best wishes,
Bart
I've managed to make my HDG with the Newton loop code running. As it is only a part of a bigger project I experienced some new problem. In order to use the command a.Apply where a is the bilinear form for the HDG formulation I need to increase the heap size by SetHeapSize(100000000). That works fine when I try to solve my equation once. Unfortunately, I would love to use it as a part of the som optimization problem and need to solve the equation in a loop with different parameters. When I solve the equation for the second time I encounter the problem with the heap size- the program freezes at the application of the form as it was because with the standard size of the heap. I believe I do something wrong with the memory management. I was trying to use the del and gc.collect() to free some memory but it did not help.
Any idea what might be the issue?
Best wishes,
Bart
Attachments:
6 years 9 months ago #356
by cwinters
Replied by cwinters on topic DG and Newtons method linearization
Hi Bart,
there was a bug in the FacetFESpace for 1d. The fix should be available in the next days.
A few comments to your code:
Best,
Christoph
there was a bug in the FacetFESpace for 1d. The fix should be available in the next days.
A few comments to your code:
- If you want to visualize a 1d function you have to use Gridfunctions. Drawing CoefficientFunctions in 1d is not working. In case you don't want to draw your functions (like Sigma, R, A, xpoints, ...) a would advise to use the as CoefficientFunctions.
Code:Sigma = IfPos(x-1200,1,0)*IfPos(-x+2400,1,0)
defines a CoefficientFunction which you can use as parameter in your BilinearForm.
- When you calculate your output functions, you use
Code:J1.vec[int(nel/2)]Code:J1(mesh(length/2))
- You do not have to delete all the variables (you del ... statement). This should be done when the PNP_solver is finished.
Best,
Christoph
6 years 9 months ago #362
by Matejczyk
Replied by Matejczyk on topic DG and Newtons method linearization
Dear Christoph,
I downloaded the new version of the library and now there is no problem with the heap size. So the update seems to work.
For the Grid/Coefficient function - I struggled a lot with plotting them and passing into my functions. As form time to time I want to plot some of them it is better to keep them as they are for now.
On more question - I would like to introduce some box constrain for a function and limit it value to (-2,2). I was trying with the Ifpos function but I'm missing the absolute value. What I would like to do is
Sigma. Set( IfPos(gd*gd-4,2*abs(gd),gd))
but the absolute value is not working. Any idea how to go over this problem?
Best wishes,
Bart
I downloaded the new version of the library and now there is no problem with the heap size. So the update seems to work.
For the Grid/Coefficient function - I struggled a lot with plotting them and passing into my functions. As form time to time I want to plot some of them it is better to keep them as they are for now.
On more question - I would like to introduce some box constrain for a function and limit it value to (-2,2). I was trying with the Ifpos function but I'm missing the absolute value. What I would like to do is
Sigma. Set( IfPos(gd*gd-4,2*abs(gd),gd))
but the absolute value is not working. Any idea how to go over this problem?
Best wishes,
Bart
- christopher
- Offline
- Administrator
Less
More
- Thank you received: 101
6 years 9 months ago - 6 years 9 months ago #363
by christopher
Replied by christopher on topic DG and Newtons method linearization
You can use the Norm CoefficientFunction, abs does not work with CFs (but I see no reason why, so I think we could add it as well...)
But if you want to limit it's values to [-2,2] you would have to cut them off at the top and the bottom:
Best
Christopher
But if you want to limit it's values to [-2,2] you would have to cut them off at the top and the bottom:
Code:
Sigma. Set( IfPos(gd-2,2, IfPos(2-gd,gd,-2)))
Christopher
Last edit: 6 years 9 months ago by christopher.
Time to create page: 0.112 seconds