Skip to content

Commit 9555375

Browse files
committed
fix readme example
1 parent 1e5ae91 commit 9555375

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

README.md

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,25 @@ This package provides force and torque computation for Magpylib objects. Its wor
99
# Example code:
1010

1111
```
12+
import numpy as np
1213
import magpylib as magpy
13-
from mforce import getFTcube
14+
from magpylib_force import getFT
1415
15-
# all inputs and output in SI units
16+
source = magpy.magnet.Sphere(diameter=1, polarization=(1,2,3))
1617
17-
cube1 = magpy.magnet.Cuboid(
18+
line = magpy.current.Polyline(
19+
current=1,
20+
vertices=((0,0,3), (-2,0,-1), (2,0,-1), (0,0,3)),
21+
)
22+
line.meshing = 10 # mesh points in each segment
23+
24+
cube = magpy.magnet.Cuboid(
1825
dimension=(1,1,1),
19-
polarization=(1,1,1),
26+
polarization=(0,0,1),
27+
position=(1,2,3)
2028
)
21-
cube2 = cube1.copy(position=(1,0,2))
22-
cube2.mesh = (10,10,10)
29+
cube.meshing = (2,2,2) # mesh grid
2330
24-
F,T = getFTcube(cube1, [cube2, cube2.copy()], anchor=(0,0,0))
25-
print(F)
26-
print(T)
31+
FT = getFT(source, [line, cube])
32+
print(FT)
2733
```

0 commit comments

Comments
 (0)