# Discussion Forum

Note: This discussion is about an older version of the COMSOL Multiphysics® software. The information provided may be out of date.

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.

## Resonating magnets

Hi folks,

Me and my team-mates are working on a project and we now need to simulate a design we made.

We have a tube with a length of 10cm and a diameter of 2cm. At both ends of the tube, say x = -5cm and x = 5cm, a fixed magnet is placed. These magnets will be of same strength. We also place a magnet in the center of the tube (x=0). If the magnet is in the center of the tube the whole system will be in equilibrium. However, when we distort this equilibrium, The middle magnet will start resonating at a certain frequency. We now want to simulate this using Comsol.
We already have managed to create the three magnets in the tube using the mfnc physics. We now need to simulate the resonating middle magnet somehow. I'd be great if someone could give us some indication on how to do this. We think it needs to be done by using Moving mesh. I've read through some tutorials provided in the knowledge base but it didn't quite help me.

Help would be appreciated:)

Many thanks,

Dirk

6 Replies Last Post Mar 27, 2013, 3:57 PM EDT
Posted: 5 years ago
Hi

if you have only MF running and get out the force on the central magnet you need to add somehow the rigid body physics to define the rest position of the magnet (with or without gravity). I would also choose ALE for the air in the tube around the floating magnet, but then "solid" is not the physics for rigid body motion, its mainly for flex motion, so I would say use rather PDE physcs and solve the Newton law F = m*a.

You can use some of the "solid" equations as baseline

--
Good luck
Ivar

Posted: 4 years ago

We did manage to get some things to work in our design, but we've encountered another problem.

Just a basic question actually, and I couldn't find an answer here at the forum. Is it possible to use a 'derived value' in the parameters section?
In our case, we want to use the force applied on the middle magnet ('mfnc.Forcex_middleMag') again to calculate the displacement of this magnet. We want to do this by using the calculated force on the middle magnet in a formula set in the parameters section, to calculate the displacement of the middle magnet. we are using parametric sweep to sweep the time value (time dependent solver didn't work somehow).

If we try it, the line in the parameters section containing 'mfnc.Forcex_middleMag' turns red and when we try to run a study, comsol gives an error.

Dirk

Posted: 4 years ago
Hi

Normally Parameters are evaluated at program/solver start, once, or in the Parameter call, your force value should be rather used in a variable definition.

I'm not sure you can use it for a parameter and have the parameter to change your geometry (nice and interesting try anyhow, pls check, perhaps it works)
normally the force would act on a "solid" physics, it might then displace the "solid" and you use ALE to map the air around to have the mesh deform along the solid motion and hence to be able to refalculate the foce based on the new position.

There is somewhere a falling magnet in a tube example, this gives one way to handle "solid" motion and MF

--
Good luck
Ivar

Posted: 4 years ago
Ivar, thanks again.

I've just looked up the falling magnet in the tube example, which seems very useful.
It somehow has great similarities with our own design.

Dirk

Posted: 4 years ago

Hi

Normally Parameters are evaluated at program/solver start, once, or in the Parameter call, your force value should be rather used in a variable definition.

I'm not sure you can use it for a parameter and have the parameter to change your geometry (nice and interesting try anyhow, pls check, perhaps it works)

Ivar,

When I use a parameter and make it dependent on t (time) and use a time-dependent solver, I see no change in geometry whatsoever. However, when I use a parametric sweep, and solve for 0t to 1t in steps of 0.1, I do see change in geometry. Pretty weird.

Another problem: when I use a variable definition for my variable and use it for the x position of the middle magnet, Comsol doesn't accept it. Comsol apparently only wants parameters used in geometry and doesn't like variables?

Dirk

Posted: 4 years ago
Hi

I do not think it's so "weird", in programming too you have "static variables" = Parameter or constants, evaluated at compiler time, and true variables (memory storage) that update with solution. Just do not mix them

Now geometry does only update on parameters, not on running solver variables, but Parameters (only exception I know about) might be updated by a "parameter solver statement"

Consider then rather deformed geometry, that could work with variables (I haven't used it recently, check the doc)

You have different types of variables, and in COMSOL scalars or fields look similar (the (x,y,z,t) dependence is implicit and not written out, except via the element reference (Domain, Boundary, Edge or Point). You need to understand this difference for local or global variables, dependent or not on the spatial coordinates and/or time. This is a notation issue, its all in the doc, but you might need to reread it a few times (I had too ;)

--
Good luck
Ivar

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.