Page 1 of 1

### Using save scalar to calculate current gives wrong output

Posted: 14 Nov 2017, 14:22
I have a simulation with two coils. Using SaveScalars to get the coil current by integration over the input / output boundary of the coil.

When the potential over both coils is 1 this seems to work fine.

All currents are zero when I set the potential over one of the coils to 0 and the other coil voltage is still 1. In this case the current density e is not 0 in one of the coils, see figure below(ParaView). But the SaveScalars output is 0 for all coil input/output boundaries.
CurrentDensityE.png

Code: Select all

``````Solver 3
Exec Solver = after all
Equation = "SaveScalars"
Procedure = File "SaveData" "SaveScalars"
Filename = File "output1.dat"
Variable 1 = Current Density e
Mask Name 1 = String "In1"
Operator 1 = boundary int
Variable 2 = Current Density e
Mask Name 2 = String "Out1"
Operator 2 = boundary int
Variable 3 = Current Density e
Mask Name 3 = String "In2"
Operator 3 = boundary int
Variable 4 = Current Density e
Mask Name 4 = String "Out2"
Operator 4 = boundary int
End

Boundary Condition 1
Name = "IN_1"
Target Boundaries(1) = 2002

AV {e} 1 = Real 0.0
AV {e} 2 = Real 0.0
AV = Real 0 ! Save scalar output seems ok when set to 1

In1 = logical True
Save Scalars = True
End

Boundary Condition 2
Name = "OUT_1"
Target Boundaries(1) = 2003
AV {e} 1 = Real 0.0
AV {e} 2 = Real 0.0
AV = Real 0

Out1 = logical True
Save Scalars = True
End

Boundary Condition 3
Name = "IN_2"
Target Boundaries(1) = 2004
AV {e} 1 = Real 0.0
AV {e} 2 = Real 0.0
AV = Real 1

In2 = logical True
Save Scalars = True
End

Boundary Condition 4
Name = "OUT_2"
Target Boundaries(1) = 2005
AV {e} 1 = Real 0.0
AV {e} 2 = Real 0.0
AV = Real 0

Out2 = logical True
Save Scalars = True
End
``````
Another question: can someone explain the difference between "current density" and "current density e"?

The complete source code and mesh can be found here:
https://github.com/boerontour/ElmerSaveScalars

Thank you in advance for the help!