magneticFoam
Hello, Foamers!
So, there is magneticFoam solver, but there isn't any tutorial. Is there anyone who could share one? I know I'm not the only one looking for it. Yours, latvietis |
Greetings latvietis and welcome to the forum!
You don't seem to be alone in wanting a tutorial for that solver:
edit: oops, only now did I read about you already knowing you aren't the only one looking... so it begs to ask: why didn't you ask on those threads instead? Best regards, Bruno |
Well, you know, they were old and there weren't any answers.
Will check those solvers. |
Ok, the problem is in the transportProperties. Before explaining I have to tell I'm total noob in OpenFOAM, I have managed to get through tutorials only. But this... Ok, so I can't find any similar tutorial (I haven't checked all yet), but how should my transportProperties file look? I don't understand what should I write there. createFields file looks like this
List<magnet> magnets(transportProperties.lookup("magnets")); surfaceScalarField murf ( IOobject ( "murf", runTime.timeName(), mesh ), mesh, 1 ); surfaceScalarField Mrf ( IOobject ( "Mrf", runTime.timeName(), mesh ), mesh, dimensionedScalar("Mr", dimensionSet(0, 1, 0, 0, 0, 1, 0), 0) ); forAll(magnets, i) { label magnetZonei = mesh.faceZones().findZoneID(magnets[i].name()); if (magnetZonei == -1) { FatalIOErrorIn(args.executable().c_str(), transportProperties) << "Cannot find faceZone for magnet " << magnets[i].name() << exit(FatalIOError); } const labelList& faces = mesh.faceZones()[magnetZonei]; const scalar muri = magnets[i].mur(); const scalar Mri = magnets[i].Mr().value(); const vector& orientationi = magnets[i].orientation(); const surfaceVectorField& Sf = mesh.Sf(); forAll(faces, i) { label facei = faces[i]; murf[facei] = muri; Mrf[facei] = Mri*(orientationi & Sf[facei]); } } |
Hi latvietis,
OK, I'll try to give you a boost based on what I know (which might not be much). So, first thing to take into account is the description available on the top comment header of "magneticFoam.C": Quote:
To go onward, first follow this tutorial: http://openfoamwiki.net/index.php/Ho...ure_to_icoFoam Then base yourself on that tutorial and the tips I tried to give you here to continue onward! Here you'll find more helpful info: http://www.openfoamworkshop.org/6th_...m/training.htm - starting with:
Bruno |
Ok, sir. I'm more confused than before, sorry. First things first, I did read the header and understood that. And here comes the bad part.. I didn't get your help.
First, about this "magnet" class. You gave me link that takes me to localPoints class reference. What should I find there? I'm really bad at reading short descriptions where most part is in C. How did you think something like that in code? What those numbers stand for? Why in that order? magnet1 0.2 5000 (0,0,1); Last is about temperature? How knowing how to add temperature could help in magnets? I'm really bad at seeing things, sorry. Thanks for those presentation links, interesting start. Yours sincerely, latvietis |
Oh, I think I got one answer to my own question.
What I need to define is found in magnet.H magnet1 0.2 5000 (0,0,1); And then it means you defined 1) name of magnet 2) mur 3) Mr 4) orientation of magnet Right? So this should be saved it transportProperties? But then again, it means that magnet is oriented in z-axis? The fields you mentioned should be saved in "0" folder? |
I kinda tried what you said, but got this:
--> FOAM FATAL IO ERROR: Attempt to return dictionary entry as a primitive file: /run/magnets/constant/transportProperties::magnets from line 20 to line 21. From function ITstream& primitiveEntry::stream() const in file db/dictionary/dictionaryEntry/dictionaryEntry.C at line 82. FOAM aborting So what is meant with 'primitive' in magnets? |
Hi latvietis,
Quote:
Quote:
And yes, the fields I listed are meant to be placed in the 0 (zero) folder. Again, the other tutorial shows the example of having to add a new field file. Quote:
A trick that I remembered that usually works is ... the bananas trick: http://openfoamwiki.net/index.php/Op...de/Use_bananas Good luck! Bruno |
I guess the problem is that I have no idea how to define transportProperties.
So I see what is needed: //- Construct from components inline magnet ( const word& name, const scalar mur, const scalar Mr, const vector& orientation ) but how it must be defined? Also what is that 'orientation'? |
I would guess orientation is supposed to point from the south to the north pole for each magnet. I'm not sure bananas will work for this constructor. How do readBegin and readEnd take input?
I wanted to add that for each magnet you will need to make a faceZone that defines the physical extent of the permanent magnet. You can use setSet or topoSet, and the name of the cellZone must have the same name as the magnet in the transportProperties. |
1 Attachment(s)
Greetings to all!
Since I have an old passion for magnetic fields and such, I had a go at creating an example myself. First of all, Marco, thanks for the hint! @latvietis: Attached is a working case named "magSandbox", albeit it doesn't necessarily represent anything very physical. Like the name implies, it's a case set-up for playing around with magneticFoam. To use it, run: Code:
./Allrun Code:
foamCleanTutorials Code:
magneticFoam -help Development details:
Best regards, Bruno |
Ok, I have a question. Is there any other ways how to tell how great this is besides adding to reputation and liking it?
But now for the good part - so, there are some results etc. But I guess I also am useless in ParaView. Any chance you could tell me how to see H and B? |
Hi latvietis,
Quote:
And the link is already accessible from where it should be accessible, namely here: http://openfoamwiki.net/index.php/Main_OFSolvers Quote:
You will only be able to see the fields on the time snapshot "1", which is accessible on the upper right corner on the Figure 2.3: http://www.openfoam.org/docs/user/cavity.php#x5-110123 Good luck! And Merry Christmas :) Bruno |
Oh, how silly, I just forgot to check volume fields in properties window. Now I can see some picks! It is time for some playing!
|
What am I defining with
1) orientation 2) topoSet To be more precise with my questions.. 1) What can I define in magnet with one vector? Something with poles? All I can think of is that for example (1 0 0) would say that my magnet is oriented in x axis with poles like this [- +]. But I don't know how scientific that could sound. What else could be called with 'orientation'? 2) In topoSet I define 2 faces for each magnet. It defines the centers of faces with given coordinates. For example (0.5 0.5 0.5) can be seen as my magnets pole center is in the middle if its 'face' is 1x1. Is that right? But why 2 faces? I believe it defines the centers of north (first) and south (second) pole. Is this the right guess? |
Hi latvietis,
Let's see: Quote:
Although, the other possibility is the usage of the "right hand rule": http://en.wikipedia.org/wiki/File:Manoderecha.svg - where the vector indicates where the thumb is pointing to. You'll have to figure that one out from the source code and the equations at hand. I didn't focus on what psi, B and H represent, I only focused on having something that simply works, looked nice and non-random. I tried with other psi values, but things got very strange and nonsensical. Quote:
This means that if the selection box were to be extended in order to pick up more faces, all of those faces would have the same magnet specification. In other words, this way of selecting faces you could have a magnet placed in the middle of the domain, with a thickness of either:
I used two magnets simply to make sure that there was a list of magnets and that said list was being properly defined and used. Each one represents an independent magnet. Their placement was only made as an example, in an attempt to have two magnets that were either deflecting or continuing a magnetic flow that wasn't linear. From another view, if I had placed the two magnets on opposite sides of the geometry, it would be harder to see any understandable results without previously knowing how things really work... which we don't know. Oh, and don't forget that important detail I mentioned near the end of the other post: Code:
The fields "murf" and "Mrf" have pre-set values when created, as shown in "createFields.H". Best regards, Bruno |
For second question I wanted to know something else. Why you define
box (0 0.999 0) (1 1.001 0.1); My explanation is the first part defines the center of Npole, second part the center of Spole. Do I understand this correctly? Good idea about right hand law, will try to figure this out. Thank you. |
Oh, no.. It means the coordinates of opposite corners? In this way I define my 'box'? But then what is this face of magnet? Where are its poles then? Defined by orientation?
|
Hi latvietis,
OK, I probably shouldn't have written so much, but I wasn't feeling artistic enough to do videos or drawings... and I'm still not in the mood to draw ;) So I'll quote myself instead: Quote:
Let's take the cavity tutorial as an example once more:
Best regards, Bruno |
1 Attachment(s)
Hello again FOAMers!
I have payed a bit with magneticFoam and I'm almost sure that it works, just want to check with some PROs and also have few questions, that I hope will be answered. 1) http://img444.imageshack.us/img444/9207/scaleds.png You see B lines from magnet. It looks kinda OK, if you ignore those 4 massive vectors from corners of magnet. What could be the reason for this kind of error? This image is scaled. 2) http://img441.imageshack.us/img441/5590/errorup.png Again B lines, but picture isn't scaled so we can see vectors in all air field. But again an error: mesh is generated using something like this: http://www.freewebs.com/mypicturesandsht/trapezoid.png Then the largest facet (b2xL) is one boundry and smallest (b1xl) is side of magnet and together as you can imagine there are 6 'blocks'. This construction was chosen because of possibility of grading mesh (closer to magnet more cells). The errors are circled in picture. The vectors are like sliding where 2 of these 'blocks' (or patches, don't know how to call them) meet. Is this a problem of mesh and there is a need for a different approach? Sincelery, latvietis P.S. And of course - case file Attachment 10837 of all this. |
1 Attachment(s)
Hi latvietis,
This is looking very nice and very good indeed! And I would also like to hear/read from the PROs on this subject as well... Here's my perspective on this: Attached is a snapshot with streamlines instead of glyphs. The steps to achieve this were:
There is an interesting detail here: since it's a single iteration of calculating field equations, the zone representing the magnet is empty inside it, but the field is still calculated as if there were cells inside the magnet! As for the concentrated glyphs/lines on the corners of the magnet - my guess is this is due to two reasons:
If you could generate a mesh that isn't so homogeneous, then it could be possible to determine if this is an error introduced by the mesh... which would still be very complicated, given the sharp corners of the magnet. One thing that is bothering me is that this magnetic field doesn't feel very real when compared to that picture on wikipedia (on the magnet page): http://en.wikipedia.org/wiki/File:Magnet0873.png - I think this is because the side wall of the magnet is being disregarded as a magnetic source. I tried merging the two N-S and even the 3 patches of the magnet into a single magnet, but the solver crashed on both tries. I then added a third magnet and associated it to the side wall of the magnet, but there was not effect. My guess is because "mag_side" has a zero gradient boundary condition for the "psi" field. I don't know enough about this to even try to give a hint in the right direction. My hunch is simply that the current boundary conditions are what they are: a North patch and a South patch sources, with no magnet in between them :( If it is meant to represent a single N-S magnet, then the streamlines near the body of the magnet should have different angles. The other detail is that bounds of the surrounding mesh seem to affect the magnetic field itself. This could really use the help of someone with more experience on magnetic field simulation ;) Best regards, Bruno |
3 Attachment(s)
Greetings!
I'm spending a lot of time to find out what magneticFoam is capable of. Firstly, thanks Bruno for meshing solution, Blender+enGrid works kinda nice though enGrid is a bit buggy and often quits without saying why. Maybe I need to find some other conversation between Blender and BlockMesh for example. Secondly, I managed to make nice (at least I think so) images with 2 magnets. Do you think they are ok? In the end I think I also managed to fill magnets with cells and it still works (it isn't showed in these pics though). But now the part where I have stopped. The thing I want to find is how magnetic field is affected by some kind of material, e.g. iron rod/wire. I also want to see how magnetic field behaves in this rod. So I have set up 2 magnet system with a plate. In image it is possible to see the outcome and it doesn't look good. I guess there are things I don't know how to define: 1) The volume inside the magnets/rod. I don't know how to define relativePermeability and remanence (from transport properties) in all volume. That means I can't define magnetic properties of my objects. I tried using boxToCell in topoSet, but I don't think it works as I want. 2) Another thing is boundary condtions of surfaces. How should I define the boundaries of my wire? zeroGradient doesn't look as the best choice, but I can't think of anything else. Yours sincerely, Martin P.S. In last image I hope you can see the 2 magnets and my rod (the largest box) perpendicular to them. |
Hi Martin,
Quote:
Er... wait, maybe this is already being done with topoSet... Quote:
Quote:
By what I can understand, it assumes the surrounding environment is either air or (most likely) vacuum. It allows you to calculate how the magnetic fields interact between magnets, but I think that you can't go any further without doing some coding of additional terms on the equations or even adding a few more equations. Quote:
Quote:
Mmmm... maybe the "calculated" boundary condition might work... Quote:
Best regards, Bruno |
Yes, the modification of solver has started, but with not much progress at the moment.
I thought about usage of "calculated" BC, but it usually just drops error message: "You are probably trying to solve for a field with a default boundary condition." I think I understand the meaning of this error, but I don't know the workaround. I believe it says that I'm solving for a field where I have defined the value of "internalField". Or something like that... How does this "calculated" BC actually work? I was looking in forums etc., but I couldn't find a simple explanation/usage of this (or maybe I lack some skills of searching). Thanks for reminding to look in other electromagnetic solvers - at least they have proper examples that could help. Best regards, Martin |
Hi Martin,
Quote:
As for searching, check the tutorials: Code:
cd $FOAM_TUTORIALS Best regards, Bruno |
Please delete this post, found my answer.
|
3 Attachment(s)
Greetings!
I'm having really hard time to find a way how to tell magneticFoam that there is also volume of magnet. I believe all my problems are in solver functions Code:
solve(fvm::laplacian(murf, psi) + fvc::div(murf*Mrf)); Do you have any suggestions what to add to solver so I could define volume of magnet not just its poles? There is another thing: since I can't define volume of magnet (I believe that is reason why), magneticFoam solves bad B-field values. They should be like the 3rd attached picture, but instead B is solved similar to H (1st and 2nd picture, they are the same though different fields are drawn). Any hints how to get proper field lines? Sincerely, Martin |
Hi Martin,
I ended up not having any spare time to look into this :( But I've remembered something that perhaps might help: porous solvers! Code:
find $FOAM_SOLVERS -iname "*porous*" Another question: I didn't see the equations you posted here in detail, but I'm wondering where exactly you placed them!? edit: About the first two pictures: how about showing in streamlines as well ;) Best regards, Bruno |
1 Attachment(s)
Oh, those equations are in magneticFoam.C file. First is to solve psi, second for H-field and last for B-field. I haven't changed them. I have tried different approaches in changing things in createfields.H. For example, I changed all face to cell so I would define one magnet in transportproperties and it should have same permeability and remanence in all volume. I could compile solver this way, but I didn't get the images I wanted.
There is another thing. I added these lines in magneticFoam.C so I could check values that I give from transportProperties: Code:
murf.write(); I attached streamline pic below (only B lines, but I can tell you that I got the same pic with H lines). Color is by psi. Ok, I'll look to that porus solver! Martin |
Hi Martin,
I was browsing the web for info on any leak about "OpenFOAM 2.2" and I picked up on this report: OpenFOAM Simulation for Electromagnetic Problems It seems to be waaaaaaaaaaaay better documented than magneticFoam ;) I've added this reference to the wiki page: http://openfoamwiki.net/index.php/MagneticFoam Best regards, Bruno |
Yeah, I'm working with this solver for some time now, it doesn't actually work that simple as explained there. Problem is with boundary conditions (that is why I have written in many threads about mapped or cyclic BCs).
Martin |
Hi Latvietis,
Did you succeed in producing the boundary conditions that would make the magnetic lines in magneticFoam look reasonable? If so, could you please share? Best regards, Goga |
Quote:
I've been working a lot with magneticFoam during the last weeks and I figured out, why remanence and relative permeability do not change. Both working examples provided in this thread use the following topoSetDict command: Code:
{ Code:
{ Greets, Björn |
James
Hey, thanks for this tutorial - very useful.
However, when I try to run it I get an error message 'Cannot find faceZone for magnet magnet1' Do you know why this is? I am very new to this kind of thing. |
3 Attachment(s)
Quote:
I wrote a more comprehensive tutorial some time ago. I posted the relevant passage below: The magnetic field of a cylindrical magnet with the following specifications is computed.
The next step is to define the geometry of the magnet itself. To this end the volume of the magnet has to be set as a faceZone via topoSet: Code:
actions Code:
magnets Code:
dimensions [0 0 0 0 0 1 0]; The first image shows the cells that are selected by cylinderToCell. The other two pictures illustrate the magnetic field (H and B) right in the middle of the geometry. Best, Bjoern |
Thanks for this response, have you got the link to the more comprehensive tutorial? I'd like to give it a go in its entirety.
|
Hey
Has anybody managed to write a code for the surrounding area of the magnets? I want to be able to see their flux lines through metal as well as through free space. Cheers James |
cannot find murf?!?
hi all,
trying to use magneticFoam... and failing ;-) so you might can help me... i'm just trying to run the example case with openfoam v1806 - and i get the following error message: --> FOAM FATAL ERROR cannot find file ".../0/murf" as far as i understand the code the murf and the Mrf fields should be created by the solver? has anybody tried to run magnetFoam on a recent openfoam version? |
Quote:
|
All times are GMT -4. The time now is 04:01. |