# Magnetostatic modelling Radia: Increasing distance between magnets a produces positive force until a certain point, beyond which force goes haywire

I have two sets of magnets. One set consists of two electromagnets (Shown below: Blue) and the other set consists of two NdFeB N40 permanent magnets. Both sets of magnets lie on the same plane. I want to plot the force of attraction/ repulsion between the two sets of magnets as the distance between them varies from 10cm to 100cm (Y-axis below is in mm - and shows the initial condition of 10cm (100mm) separation). I have modeled this setup using Radia Free software found here. You must have Mathematica (I am currently using version 11.2) to use Radia.

My problem: When Radia solves the model and produces an output of Force vs. Distance I expect ALL the force measurements to be EITHER positive OR negative - meaning either attraction or repulsion between the two sets of magnets. What actually happens though is after about 50cm separation Radia produces a mixture of positive and negative force results. The First plot looks accurate (yellow and blue lines) but on closer inspection some of the values are negative and this becomes glaringly obvious when the Force axis (Y) is made logarithmic. And the logarithmic version: Included in the graph (orange) is the solution I obtained (Force vs. Distance) from a 2D magnetostatics software called FEMM. This is purely a reference (which I believe is what the yellow and blue lines should look like especially in the logarithmic version) showing a Force>0 for all distances from 10cm to 100cm.

I don't know where I am going wrong and would really appreciate some help. I have read on the Radia documentation that correct subdivision is crucial - especially to iron components. I have tried to subdivide my iron core using radObjDivMag[] Radia Functions but I can't get it to work (keep in mind I used the same function on a bar magnet (cuboid) and the function worked perfectly, I have also tried to use the function argument {"cyl",....} but it will still not subdivide my component, if you know where I am going wrong please comment).

I would like to attach my Mathematica notebook (heavily commented however if you have any questions please ask me) which I used to create and solve the model and the Excel spreadsheet used to plot my data but don't seem to be able to - Please message me and I can send it to you.

Has anyone used Radia before? Should I be using different software?

• There is certainly not enough information in the question. We will be primarily interested in the set of the equations you are solving (math formulation), as well as the code. You can upload the code and data and attach it to the question if they are very large; however, I would suggest finding a small example where you see this problem. Mar 20, 2018 at 13:13
• The graph makes it look like it could be a catastrophic cancellation issue, e.g., if the force is computed as a difference of two approximately equal forces (I don't know if that's how your model does it though). Mar 20, 2018 at 23:37