Diff of /trunk/finley/test/python/run_models.py

revision 2654 by gross, Tue Sep 8 07:11:12 2009 UTC revision 2663 by gross, Tue Sep 15 06:04:44 2009 UTC
# Line 1096  class Test_IncompressibleIsotropicFlowCa Line 1096  class Test_IncompressibleIsotropicFlowCa
1096  class Test_FaultSystem(unittest.TestCase):  class Test_FaultSystem(unittest.TestCase):
1097     EPS=1.e-8     EPS=1.e-8
1098     NE=10     NE=10
1099     def test_Fault2D_MaxValue(self):     def test_Fault_MaxValue(self):
1100        dom=Rectangle(2*self.NE,2*self.NE)        dom=Rectangle(2*self.NE,2*self.NE)
1101        x=dom.getX()        x=dom.getX()
1102        f=FaultSystem(dim=2)        f=FaultSystem(dim=2)
1103        f.addFault([[0.5,0.],[0.,0.5]], tag=1)        f.addFault(V0=[0.5,0.], strikes=[3.*pi/4], ls=[0.70710678118654757], tag=1)
1104        f.addFault([[1.,0.5],[0.5,0.5],[0.5,1.]], tag=2)        f.addFault(V0=[1.,0.5], strikes=[pi, pi/2], ls=[0.5,0.5], tag=2)
1105
1106        m, t, l=f.getMaxValue(x[0]*(1.-x[0])*(1-x[1]))        m, t, l=f.getMaxValue(x[0]*(1.-x[0])*(1-x[1]))
1107        self.failUnless(  m == 0.25, "wrong max value")        self.failUnless(  m == 0.25, "wrong max value")
# Line 1125  class Test_FaultSystem(unittest.TestCase Line 1125  class Test_FaultSystem(unittest.TestCase
1125        self.failUnless(  abs(l-0.70710678118654) <= self.EPS,  "wrong max location")        self.failUnless(  abs(l-0.70710678118654) <= self.EPS,  "wrong max location")
1126
1127
1128     def test_Fault2D_TwoFaults(self):     def test_Fault2D(self):
1129        f=FaultSystem(dim=2)        f=FaultSystem(dim=2)
1130        top1=[ [1.,0.], [1.,1.], [0.,1.] ]        top1=[ [1.,0.], [1.,1.], [0.,1.] ]
1131        self.failUnlessRaises(ValueError,f.addFault,top=top1,tag=1,bottom=top1)        self.failUnlessRaises(ValueError,f.addFault,V0=[1.,0],strikes=[pi/2, pi/2],ls=[1.,1.],tag=1,dips=top1)
1132        f.addFault(top=top1,tag=1)        f.addFault(V0=[1.,0],strikes=[pi/2, pi],ls=[1.,1.],tag=1)
1133        self.failUnless(f.getDim() == 2, "wrong dimension")        self.failUnless(f.getDim() == 2, "wrong dimension")
1134        self.failUnless( [ 1 ] == f.getTags(), "tags wrong")        self.failUnless( [ 1 ] == f.getTags(), "tags wrong")
1135        self.failUnless(  2. == f.getLength(1), "length wrong")        self.failUnless(  2. == f.getTotalLength(1), "length wrong")
1136        self.failUnless(  0. == f.getDepth(1), "depth wrong")        self.failUnless(  0. == f.getMediumDepth(1), "depth wrong")
1137        self.failUnless( (0., 2.) ==  f.getW0Range(1)," wrong W0 range")        self.failUnless( (0., 2.) ==  f.getW0Range(1)," wrong W0 range")
1138        self.failUnless( (0., 0.) ==  f.getW1Range(1)," wrong W1 range")        self.failUnless( (0., 0.) ==  f.getW1Range(1)," wrong W1 range")
1139        self.failUnless( [0., 1., 2.] ==  f.getW0Offsets(1)," wrong W0 offsets")        self.failUnless( [0., 1., 2.] ==  f.getW0Offsets(1)," wrong W0 offsets")
1140        segs=f.getFaultSegments(1)[0]        segs=f.getTopPolyline(1)
1141        self.failUnless( len(segs) == 3, "wrong number of segments")        self.failUnless( len(segs) == 3, "wrong number of segments")
1142        self.failUnless( isinstance(segs[0], numpy.ndarray), "wrong class of vertex 0")        self.failUnless( isinstance(segs[0], numpy.ndarray), "wrong class of vertex 0")
1143        self.failUnless( segs[0].size == 2, "seg 0 has wrong size.")        self.failUnless( segs[0].size == 2, "seg 0 has wrong size.")
# Line 1153  class Test_FaultSystem(unittest.TestCase Line 1153  class Test_FaultSystem(unittest.TestCase
1153        self.failUnless( c.size == 2, "center size is wrong")        self.failUnless( c.size == 2, "center size is wrong")
1154        self.failUnless( numpy.linalg.norm(c-[2./3.,2./3.]) < self.EPS, "center has wrong coordinates.")        self.failUnless( numpy.linalg.norm(c-[2./3.,2./3.]) < self.EPS, "center has wrong coordinates.")
1155        o=f.getOrientationOnSurface()/pi*180.        o=f.getOrientationOnSurface()/pi*180.
1156        self.failUnless( abs(o-45.) < self.EPS, "wrong orientation.")        self.failUnless( abs(o+45.) < self.EPS, "wrong orientation.")
1157
1158        top2=[ [10.,0.], [0.,10.] ]        top2=[ [10.,0.], [0.,10.] ]
1159        f.addFault(top2, tag=2, w0_offsets=[0,20], w1_max=20)        f.addFault(V0=[10.,0],strikes=[3.*pi/4],ls=[14.142135623730951], tag=2, w0_offsets=[0,20], w1_max=20)
1160        self.failUnless( [ 1, 2 ] == f.getTags(), "tags wrong")        self.failUnless( [ 1, 2 ] == f.getTags(), "tags wrong")
1161        self.failUnless(  abs(f.getLength(2)-14.1421356237) < self.EPS * 14.1421356237, "wrong length")        self.failUnless(  abs(f.getTotalLength(2)-14.1421356237) < self.EPS * 14.1421356237, "wrong length")
1162        self.failUnless(  0. == f.getDepth(2), "depth wrong")        self.failUnless(  0. == f.getMediumDepth(2), "depth wrong")
1163        self.failUnless( (0., 20.) ==  f.getW0Range(2)," wrong W0 range")        self.failUnless( (0., 20.) ==  f.getW0Range(2)," wrong W0 range")
1164        self.failUnless( (0., 0.) ==  f.getW1Range(2)," wrong W1 range")        self.failUnless( (0., 0.) ==  f.getW1Range(2)," wrong W1 range")
1165        self.failUnless( [0., 20.] ==  f.getW0Offsets(2)," wrong W0 offsets")        self.failUnless( [0., 20.] ==  f.getW0Offsets(2)," wrong W0 offsets")
1166        segs=f.getFaultSegments(2)[0]        segs=f.getTopPolyline(2)
1167        self.failUnless( len(segs) == 2, "wrong number of segments")        self.failUnless( len(segs) == 2, "wrong number of segments")
1168        self.failUnless( isinstance(segs[0], numpy.ndarray), "wrong class of vertex 0")        self.failUnless( isinstance(segs[0], numpy.ndarray), "wrong class of vertex 0")
1169        self.failUnless( numpy.linalg.norm(segs[0]-[10.,0.]) < self.EPS, "wrong vertex. 0 ")        self.failUnless( numpy.linalg.norm(segs[0]-[10.,0.]) < self.EPS, "wrong vertex. 0 ")
# Line 1174  class Test_FaultSystem(unittest.TestCase Line 1174  class Test_FaultSystem(unittest.TestCase
1174        self.failUnless( c.size == 2, "center size is wrong")        self.failUnless( c.size == 2, "center size is wrong")
1175        self.failUnless( numpy.linalg.norm(c-[12./5.,12./5.]) < self.EPS, "center has wrong coordinates.")        self.failUnless( numpy.linalg.norm(c-[12./5.,12./5.]) < self.EPS, "center has wrong coordinates.")
1176        o=f.getOrientationOnSurface()/pi*180.        o=f.getOrientationOnSurface()/pi*180.
1177        self.failUnless( abs(o-45.) < self.EPS, "wrong orientation.")        self.failUnless( abs(o+45.) < self.EPS, "wrong orientation.")
1178
1179        s,d=f.getSideAndDistance([0.,0.], tag=1)        s,d=f.getSideAndDistance([0.,0.], tag=1)
1180        self.failUnless( s<0, "wrong side.")        self.failUnless( s<0, "wrong side.")
# Line 1201  class Test_FaultSystem(unittest.TestCase Line 1201  class Test_FaultSystem(unittest.TestCase
1201
1202        f.transform(rot=-pi/2., shift=[-1.,-1.])        f.transform(rot=-pi/2., shift=[-1.,-1.])
1203        self.failUnless( [ 1, 2 ] == f.getTags(), "tags after transformation wrong")        self.failUnless( [ 1, 2 ] == f.getTags(), "tags after transformation wrong")
1204        self.failUnless(  2. == f.getLength(1), "length after transformation wrong")        self.failUnless(  2. == f.getTotalLength(1), "length after transformation wrong")
1205        self.failUnless(  0. == f.getDepth(1), "depth after transformation wrong")        self.failUnless(  0. == f.getMediumDepth(1), "depth after transformation wrong")
1206        self.failUnless( (0., 2.) ==  f.getW0Range(1)," wrong W0 after transformation range")        self.failUnless( (0., 2.) ==  f.getW0Range(1)," wrong W0 after transformation range")
1207        self.failUnless( (0., 0.) ==  f.getW1Range(1)," wrong W1 rangeafter transformation ")        self.failUnless( (0., 0.) ==  f.getW1Range(1)," wrong W1 rangeafter transformation ")
1208        self.failUnless( [0., 1., 2.] ==  f.getW0Offsets(1)," wrong W0 offsetsafter transformation ")        self.failUnless( [0., 1., 2.] ==  f.getW0Offsets(1)," wrong W0 offsetsafter transformation ")
1209        segs=f.getFaultSegments(1)[0]        segs=f.getTopPolyline(1)
1210        self.failUnless( len(segs) == 3, "wrong number of segmentsafter transformation ")        self.failUnless( len(segs) == 3, "wrong number of segmentsafter transformation ")
1211        self.failUnless( isinstance(segs[0], numpy.ndarray), "wrong class of vertex 0 after transformation")        self.failUnless( isinstance(segs[0], numpy.ndarray), "wrong class of vertex 0 after transformation")
1212        self.failUnless( segs[0].size == 2, "seg 0 has wrong size after transformation.")        self.failUnless( segs[0].size == 2, "seg 0 has wrong size after transformation.")
# Line 1217  class Test_FaultSystem(unittest.TestCase Line 1217  class Test_FaultSystem(unittest.TestCase
1217        self.failUnless( isinstance(segs[2], numpy.ndarray), "wrong class of vertex  after transformation2")        self.failUnless( isinstance(segs[2], numpy.ndarray), "wrong class of vertex  after transformation2")
1218        self.failUnless( segs[2].size == 2, "seg 2 has wrong size after transformation.")        self.failUnless( segs[2].size == 2, "seg 2 has wrong size after transformation.")
1219        self.failUnless( numpy.linalg.norm(segs[2]-[0., 1.]) < self.EPS, "wrong vertex after transformation. 2 ")        self.failUnless( numpy.linalg.norm(segs[2]-[0., 1.]) < self.EPS, "wrong vertex after transformation. 2 ")
1220        self.failUnless(  abs(f.getLength(2)-14.1421356237) < self.EPS * 14.1421356237, "wrong length after transformation")        self.failUnless(  abs(f.getTotalLength(2)-14.1421356237) < self.EPS * 14.1421356237, "wrong length after transformation")
1221        self.failUnless(  0. == f.getDepth(2), "depth wrong after transformation")        self.failUnless(  0. == f.getMediumDepth(2), "depth wrong after transformation")
1222        self.failUnless( (0., 20.) ==  f.getW0Range(2)," wrong W0 range after transformation")        self.failUnless( (0., 20.) ==  f.getW0Range(2)," wrong W0 range after transformation")
1223        self.failUnless( (0., 0.) ==  f.getW1Range(2)," wrong W1 range after transformation")        self.failUnless( (0., 0.) ==  f.getW1Range(2)," wrong W1 range after transformation")
1224        self.failUnless( [0., 20.] ==  f.getW0Offsets(2)," wrong W0 offsets after transformation")        self.failUnless( [0., 20.] ==  f.getW0Offsets(2)," wrong W0 offsets after transformation")
1225        segs=f.getFaultSegments(2)[0]        segs=f.getTopPolyline(2)
1226        self.failUnless( len(segs) == 2, "wrong number of segments after transformation")        self.failUnless( len(segs) == 2, "wrong number of segments after transformation")
1227        self.failUnless( isinstance(segs[0], numpy.ndarray), "wrong class of vertex 0 after transformation")        self.failUnless( isinstance(segs[0], numpy.ndarray), "wrong class of vertex 0 after transformation")
1228        self.failUnless( numpy.linalg.norm(segs[0]-[-1.,-9]) < self.EPS, "wrong vertex. 0  after transformation")        self.failUnless( numpy.linalg.norm(segs[0]-[-1.,-9]) < self.EPS, "wrong vertex. 0  after transformation")
# Line 1234  class Test_FaultSystem(unittest.TestCase Line 1234  class Test_FaultSystem(unittest.TestCase
1234        self.failUnless( c.size == 2, "center size is wrong")        self.failUnless( c.size == 2, "center size is wrong")
1235        self.failUnless( numpy.linalg.norm(c-[7./5.,-7./5.]) < self.EPS, "center has wrong coordinates.")        self.failUnless( numpy.linalg.norm(c-[7./5.,-7./5.]) < self.EPS, "center has wrong coordinates.")
1236        o=f.getOrientationOnSurface()/pi*180.        o=f.getOrientationOnSurface()/pi*180.
1237        self.failUnless( abs(o+45.) < self.EPS, "wrong orientation.")        self.failUnless( abs(o-45.) < self.EPS, "wrong orientation.")
1238
1239        p=f.getParametrization([-1.,0.],1)        p=f.getParametrization([-1.,0.],1)
1240        self.failUnless(p[1]==1., "wrong value.")        self.failUnless(p[1]==1., "wrong value.")
# Line 1267  class Test_FaultSystem(unittest.TestCase Line 1267  class Test_FaultSystem(unittest.TestCase
1267        self.failUnless(p[1]==1., "wrong value.")        self.failUnless(p[1]==1., "wrong value.")
1268        self.failUnless(abs(p[0]-20.)<self.EPS, "wrong value.")        self.failUnless(abs(p[0]-20.)<self.EPS, "wrong value.")
1269
1270       def test_Fault3D(self):
1271          f=FaultSystem(dim=3)
1272          self.failUnless(f.getDim() == 3, "wrong dimension")
1273
1274          top1=[ [0.,0.,0.], [1., 0., 0.] ]
1275          f.addFault(V0=[0.,0,0],strikes=[0.],ls=[1.,], dips=pi/2, depths=20.,tag=1)
1276          self.failUnless( [ 1 ] == f.getTags(), "tags wrong")
1277          self.failUnless(  1. == f.getTotalLength(1), "length wrong")
1278          self.failUnless(  20. == f.getMediumDepth(1), "depth wrong")
1279          self.failUnless( (0., 1.) ==  f.getW0Range(1)," wrong W0 range")
1280          self.failUnless( (-20., 0.) ==  f.getW1Range(1)," wrong W1 range")
1281          self.failUnless( [0., 1.] ==  f.getW0Offsets(1)," wrong W0 offsets")
1282          segs=f.getTopPolyline(1)
1283          self.failUnless( len(segs) == 2, "wrong number of segments")
1284          self.failUnless( isinstance(segs[0], numpy.ndarray), "wrong class of vertex 0")
1285          self.failUnless( segs[0].size == 3, "seg 0 has wrong size.")
1286          self.failUnless( numpy.linalg.norm(segs[0]-[0.,0.,0.]) < self.EPS, "wrong vertex. 0 ")
1287          self.failUnless( isinstance(segs[1], numpy.ndarray), "wrong class of vertex 1")
1288          self.failUnless( segs[1].size == 3, "seg 1 has wrong size.")
1289          self.failUnless( numpy.linalg.norm(segs[1]-[1.,0.,0]) < self.EPS, "wrong vertex. 1 ")
1290          c=f.getCenterOnSurface()
1291          self.failUnless( isinstance(c, numpy.ndarray), "center has wrong class")
1292          self.failUnless( c.size == 3, "center size is wrong")
1293          self.failUnless( numpy.linalg.norm(c-[0.5,0.,0.]) < self.EPS, "center has wrong coordinates.")
1294          o=f.getOrientationOnSurface()/pi*180.
1295          self.failUnless( abs(o) < self.EPS, "wrong orientation.")
1296          d=f.getDips(1)
1297          self.failUnless( len(d) == 1, "wrong number of dips")
1298          self.failUnless(  abs(d[0]-1.5707963267948966) < self.EPS, "wrong dip 0")
1299          sn=f.getSegmentNormals(1)
1300          self.failUnless( len(sn) == 1, "wrong number of normals")
1301          self.failUnless( isinstance(sn[0], numpy.ndarray), "wrong class of bottom vertex 0")
1302          self.failUnless( numpy.linalg.norm(sn[0]-[0, -1., 0.]) < self.EPS, "wrong bottom vertex 1 ")
1303          dv=f.getDepthVectors(1)
1304          self.failUnless( len(dv) == 2, "wrong number of depth vectors.")
1305          self.failUnless( isinstance(dv[0], numpy.ndarray), "wrong class of depth vector 0")
1306          self.failUnless( numpy.linalg.norm(dv[0]-[0., 0., -20.]) < self.EPS, "wrong depth vector 0 ")
1307          self.failUnless( isinstance(dv[1], numpy.ndarray), "wrong class of depth vector 1")
1308          self.failUnless( numpy.linalg.norm(dv[1]-[0., 0., -20.]) < self.EPS, "wrong depth vector 1 ")
1309          b=f.getBottomPolyline(1)
1310          self.failUnless( len(b) == 2, "wrong number of bottom vertices")
1311          self.failUnless( isinstance(b[0], numpy.ndarray), "wrong class of bottom vertex 0")
1312          self.failUnless( numpy.linalg.norm(b[0]-[0., 0., -20.]) < self.EPS, "wrong bottom vertex 0 ")
1313          self.failUnless( isinstance(b[1], numpy.ndarray), "wrong class of bottom vertex 1")
1314          self.failUnless( numpy.linalg.norm(b[1]-[1., 0., -20.]) < self.EPS, "wrong bottom vertex 1 ")
1315          ds=f.getDepths(1)
1316          self.failUnless( len(ds) == 2, "wrong number of depth")
1317          self.failUnless( abs(ds[0]-20.) < self.EPS, "wrong depth at vertex 0 ")
1318          self.failUnless( abs(ds[1]-20.) < self.EPS, "wrong depth at vertex 1 ")
1319
1320          top2=[ [0.,0.,0.], [0., 10., 0.] ]
1321          f.addFault(V0=[0.,0,0],strikes=[pi/2],ls=[10.,], dips=pi/2, depths=20.,tag=2)
1322          self.failUnless( [ 1, 2 ] == f.getTags(), "tags wrong")
1323          self.failUnless(  10. == f.getTotalLength(2), "length wrong")
1324          self.failUnless(  20. == f.getMediumDepth(2), "depth wrong")
1325          self.failUnless( (0., 10.) ==  f.getW0Range(2)," wrong W0 range")
1326          self.failUnless( (-20., 0.) ==  f.getW1Range(2)," wrong W1 range")
1327          self.failUnless( [0., 10.] ==  f.getW0Offsets(2)," wrong W0 offsets")
1328          segs=f.getTopPolyline(2)
1329          self.failUnless( len(segs) == 2, "wrong number of segments")
1330          self.failUnless( isinstance(segs[0], numpy.ndarray), "wrong class of vertex 0")
1331          self.failUnless( segs[0].size == 3, "seg 0 has wrong size.")
1332          self.failUnless( numpy.linalg.norm(segs[0]-[0.,0.,0.]) < self.EPS, "wrong vertex. 0 ")
1333          self.failUnless( isinstance(segs[1], numpy.ndarray), "wrong class of vertex 1")
1334          self.failUnless( segs[1].size == 3, "seg 1 has wrong size.")
1335          self.failUnless( numpy.linalg.norm(segs[1]-[0., 10., 0]) < self.EPS, "wrong vertex. 1 ")
1336          d=f.getDips(2)
1337          self.failUnless( len(d) == 1, "wrong number of dips")
1338          self.failUnless(  abs(d[0]-1.5707963267948966) < self.EPS, "wrong dip 0")
1339          sn=f.getSegmentNormals(2)
1340          self.failUnless( len(sn) == 1, "wrong number of normals")
1341          self.failUnless( isinstance(sn[0], numpy.ndarray), "wrong class of bottom vertex 0")
1342          self.failUnless( numpy.linalg.norm(sn[0]-[1, 0., 0.]) < self.EPS, "wrong bottom vertex 1 ")
1343          dv=f.getDepthVectors(2)
1344          self.failUnless( len(dv) == 2, "wrong number of depth vectors.")
1345          self.failUnless( isinstance(dv[0], numpy.ndarray), "wrong class of depth vector 0")
1346          self.failUnless( numpy.linalg.norm(dv[0]-[0., 0., -20.]) < self.EPS, "wrong depth vector 0 ")
1347          self.failUnless( isinstance(dv[1], numpy.ndarray), "wrong class of depth vector 1")
1348          self.failUnless( numpy.linalg.norm(dv[1]-[0., 0., -20.]) < self.EPS, "wrong depth vector 1 ")
1349          b=f.getBottomPolyline(2)
1350          self.failUnless( len(b) == 2, "wrong number of bottom vertices")
1351          self.failUnless( isinstance(b[0], numpy.ndarray), "wrong class of bottom vertex 0")
1352          self.failUnless( numpy.linalg.norm(b[0]-[0., 0., -20.]) < self.EPS, "wrong bottom vertex 0 ")
1353          self.failUnless( isinstance(b[1], numpy.ndarray), "wrong class of bottom vertex 1")
1354          self.failUnless( numpy.linalg.norm(b[1]-[0., 10., -20.]) < self.EPS, "wrong bottom vertex 1 ")
1355          ds=f.getDepths(2)
1356          self.failUnless( len(ds) == 2, "wrong number of depth")
1357          self.failUnless( abs(ds[0]-20.) < self.EPS, "wrong depth at vertex 0 ")
1358          self.failUnless( abs(ds[1]-20.) < self.EPS, "wrong depth at vertex 1 ")
1359
1360          top2=[ [10.,0.,0.], [0., 10., 0.] ]
1361          f.addFault(V0=[10.,0,0],strikes=3*pi/4,ls=14.142135623730951, dips=pi/2, depths=30.,tag=2)
1362          self.failUnless( [ 1, 2 ] == f.getTags(), "tags wrong")
1363          self.failUnless(  abs(14.142135623730951 - f.getTotalLength(2)) <self.EPS, "length wrong")
1364          self.failUnless(  30. == f.getMediumDepth(2), "depth wrong")
1365          self.failUnless( (-30., 0.) ==  f.getW1Range(2)," wrong W1 range")
1366          segs=f.getTopPolyline(2)
1367          self.failUnless( len(segs) == 2, "wrong number of segments")
1368          self.failUnless( isinstance(segs[0], numpy.ndarray), "wrong class of vertex 0")
1369          self.failUnless( segs[0].size == 3, "seg 0 has wrong size.")
1370          self.failUnless( numpy.linalg.norm(segs[0]-[10.,0.,0.]) < self.EPS, "wrong vertex. 0 ")
1371          self.failUnless( isinstance(segs[1], numpy.ndarray), "wrong class of vertex 1")
1372          self.failUnless( segs[1].size == 3, "seg 1 has wrong size.")
1373          self.failUnless( numpy.linalg.norm(segs[1]-[0., 10., 0]) < self.EPS, "wrong vertex. 1 ")
1374          d=f.getDips(2)
1375          self.failUnless( len(d) == 1, "wrong number of dips")
1376          self.failUnless(  abs(d[0]-1.5707963267948966) < self.EPS, "wrong dip 0")
1377          sn=f.getSegmentNormals(2)
1378          self.failUnless( len(sn) == 1, "wrong number of normals")
1379          self.failUnless( isinstance(sn[0], numpy.ndarray), "wrong class of bottom vertex 0")
1380          self.failUnless( numpy.linalg.norm(sn[0]-[0.70710678118654746, 0.70710678118654746, 0.]) < self.EPS, "wrong bottom vertex 1 ")
1381          dv=f.getDepthVectors(2)
1382          self.failUnless( len(dv) == 2, "wrong number of depth vectors.")
1383          self.failUnless( isinstance(dv[0], numpy.ndarray), "wrong class of depth vector 0")
1384          self.failUnless( numpy.linalg.norm(dv[0]-[0., 0., -30.]) < self.EPS, "wrong depth vector 0 ")
1385          self.failUnless( isinstance(dv[1], numpy.ndarray), "wrong class of depth vector 1")
1386          self.failUnless( numpy.linalg.norm(dv[1]-[0., 0., -30.]) < self.EPS, "wrong depth vector 1 ")
1387          b=f.getBottomPolyline(2)
1388          self.failUnless( len(b) == 2, "wrong number of bottom vertices")
1389          self.failUnless( isinstance(b[0], numpy.ndarray), "wrong class of bottom vertex 0")
1390          self.failUnless( numpy.linalg.norm(b[0]-[10., 0., -30.]) < self.EPS, "wrong bottom vertex 0 ")
1391          self.failUnless( isinstance(b[1], numpy.ndarray), "wrong class of bottom vertex 1")
1392          self.failUnless( numpy.linalg.norm(b[1]-[0., 10., -30.]) < self.EPS, "wrong bottom vertex 1 ")
1393          ds=f.getDepths(2)
1394          self.failUnless( len(ds) == 2, "wrong number of depth")
1395          self.failUnless( abs(ds[0]-30.) < self.EPS, "wrong depth at vertex 0 ")
1396          self.failUnless( abs(ds[1]-30.) < self.EPS, "wrong depth at vertex 1 ")
1397
1398          top2=[ [10.,0.,0.], [0., 10., 0.] ]
1399          f.addFault(V0=[10.,0,0],strikes=3*pi/4,ls=14.142135623730951, dips=pi/4, depths=50.,tag=2)
1400          self.failUnless( [ 1, 2 ] == f.getTags(), "tags wrong")
1401          self.failUnless(  abs(14.142135623730951 - f.getTotalLength(2)) <self.EPS, "length wrong")
1402          self.failUnless(  50. == f.getMediumDepth(2), "depth wrong")
1403          self.failUnless( (-50., 0.) ==  f.getW1Range(2)," wrong W1 range")
1404          segs=f.getTopPolyline(2)
1405          self.failUnless( len(segs) == 2, "wrong number of segments")
1406          self.failUnless( isinstance(segs[0], numpy.ndarray), "wrong class of vertex 0")
1407          self.failUnless( segs[0].size == 3, "seg 0 has wrong size.")
1408          self.failUnless( numpy.linalg.norm(segs[0]-[10.,0.,0.]) < self.EPS, "wrong vertex. 0 ")
1409          self.failUnless( isinstance(segs[1], numpy.ndarray), "wrong class of vertex 1")
1410          self.failUnless( segs[1].size == 3, "seg 1 has wrong size.")
1411          self.failUnless( numpy.linalg.norm(segs[1]-[0., 10., 0]) < self.EPS, "wrong vertex. 1 ")
1412          d=f.getDips(2)
1413          self.failUnless( len(d) == 1, "wrong number of dips")
1414          self.failUnless(  abs(d[0]-0.78539816339744828) < self.EPS, "wrong dip 0")
1415          sn=f.getSegmentNormals(2)
1416          self.failUnless( len(sn) == 1, "wrong number of normals")
1417          self.failUnless( isinstance(sn[0], numpy.ndarray), "wrong class of bottom vertex 0")
1418          self.failUnless( numpy.linalg.norm(sn[0]-[0.5,0.5,0.70710678118654746]) < self.EPS, "wrong bottom vertex 1 ")
1419          dv=f.getDepthVectors(2)
1420          self.failUnless( len(dv) == 2, "wrong number of depth vectors.")
1421          self.failUnless( isinstance(dv[0], numpy.ndarray), "wrong class of depth vector 0")
1422          self.failUnless( numpy.linalg.norm(dv[0]-[25., 25., -35.355339059327378]) < self.EPS, "wrong depth vector 0 ")
1423          self.failUnless( isinstance(dv[1], numpy.ndarray), "wrong class of depth vector 1")
1424          self.failUnless( numpy.linalg.norm(dv[1]-[25.,25., -35.355339059327378]) < self.EPS, "wrong depth vector 1 ")
1425          b=f.getBottomPolyline(2)
1426          self.failUnless( len(b) == 2, "wrong number of bottom vertices")
1427          self.failUnless( isinstance(b[0], numpy.ndarray), "wrong class of bottom vertex 0")
1428          self.failUnless( numpy.linalg.norm(b[0]-[35., 25., -35.355339059327378]) < self.EPS, "wrong bottom vertex 0 ")
1429          self.failUnless( isinstance(b[1], numpy.ndarray), "wrong class of bottom vertex 1")
1430          self.failUnless( numpy.linalg.norm(b[1]-[25, 35., -35.355339059327378]) < self.EPS, "wrong bottom vertex 1 ")
1431          ds=f.getDepths(2)
1432          self.failUnless( len(ds) == 2, "wrong number of depth")
1433          self.failUnless( abs(ds[0]-50.) < self.EPS, "wrong depth at vertex 0 ")
1434          self.failUnless( abs(ds[1]-50.) < self.EPS, "wrong depth at vertex 1 ")
1435
1436          top1=[ [10.,0.,0], [10.,10.,0], [0.,10.,0] ]
1437          f.addFault(V0=[10.,0.,0.],strikes=[pi/2, pi],ls=[10.,10.],tag=1, dips=pi/4, depths=20.)
1438          self.failUnless(  20. == f.getTotalLength(1), "length wrong")
1439          self.failUnless(  20. == f.getMediumDepth(1), "depth wrong")
1440          segs=f.getTopPolyline(1)
1441          self.failUnless( len(segs) == 3, "wrong number of segments")
1442          self.failUnless( isinstance(segs[0], numpy.ndarray), "wrong class of vertex 0")
1443          self.failUnless( segs[0].size == 3, "seg 0 has wrong size.")
1444          self.failUnless( numpy.linalg.norm(segs[0]-[10.,0.,0.]) < self.EPS, "wrong vertex. 0 ")
1445          self.failUnless( isinstance(segs[1], numpy.ndarray), "wrong class of vertex 1")
1446          self.failUnless( segs[1].size == 3, "seg 1 has wrong size.")
1447          self.failUnless( numpy.linalg.norm(segs[1]-[10.,10.,0.]) < self.EPS, "wrong vertex. 1 ")
1448          self.failUnless( isinstance(segs[2], numpy.ndarray), "wrong class of vertex 2")
1449          self.failUnless( segs[2].size == 3, "seg 2 has wrong size.")
1450          self.failUnless( numpy.linalg.norm(segs[2]-[0.,10.,0.]) < self.EPS, "wrong vertex. 2 ")
1451          d=f.getDips(1)
1452          self.failUnless( len(d) == 2, "wrong number of dips")
1453          self.failUnless(  abs(d[0]-0.78539816339744828) < self.EPS, "wrong dip 0")
1454          self.failUnless(  abs(d[1]-0.78539816339744828) < self.EPS, "wrong dip 0")
1455          ds=f.getDepths(1)
1456          self.failUnless( len(ds) == 3, "wrong number of depth")
1457          self.failUnless( abs(ds[0]-20.) < self.EPS, "wrong depth at vertex 0 ")
1458          self.failUnless( abs(ds[1]-20.) < self.EPS, "wrong depth at vertex 1 ")
1459          sn=f.getSegmentNormals(1)
1460          self.failUnless( len(sn) == 2, "wrong number of normals")
1461          self.failUnless( isinstance(sn[0], numpy.ndarray), "wrong class of bottom vertex 0")
1462          self.failUnless( numpy.linalg.norm(sn[0]-[0.70710678118654746,0.,0.70710678118654746]) < self.EPS, "wrong bottom vertex 1 ")
1463          self.failUnless( isinstance(sn[1], numpy.ndarray), "wrong class of bottom vertex 0")
1464          self.failUnless( numpy.linalg.norm(sn[1]-[0.,0.70710678118654746,0.70710678118654746]) < self.EPS, "wrong bottom vertex 1 ")
1465          dv=f.getDepthVectors(1)
1466          self.failUnless( len(dv) == 3, "wrong number of depth vectors.")
1467          self.failUnless( isinstance(dv[0], numpy.ndarray), "wrong class of depth vector 0")
1468          self.failUnless( numpy.linalg.norm(dv[0]-[14.142135623730951, 0., -14.142135623730951]) < self.EPS, "wrong depth vector 0 ")
1469          self.failUnless( isinstance(dv[1], numpy.ndarray), "wrong class of depth vector 1")
1470          self.failUnless( numpy.linalg.norm(dv[1]-[11.547005383792515,11.547005383792515, -11.547005383792515]) < self.EPS, "wrong depth vector 2 ")
1471          self.failUnless( isinstance(dv[2], numpy.ndarray), "wrong class of depth vector 1")
1472          self.failUnless( numpy.linalg.norm(dv[2]-[0.,14.142135623730951, -14.142135623730951]) < self.EPS, "wrong depth vector 2 ")
1473          segs=f.getBottomPolyline(1)
1474          self.failUnless( len(segs) == 3, "wrong number of segments")
1475          self.failUnless( isinstance(segs[0], numpy.ndarray), "wrong class of vertex 0")
1476          self.failUnless( segs[0].size == 3, "seg 0 has wrong size.")
1477          self.failUnless( numpy.linalg.norm(segs[0]-[24.142135623730951,0.,-14.142135623730951]) < self.EPS, "wrong vertex. 0 ")
1478          self.failUnless( isinstance(segs[1], numpy.ndarray), "wrong class of vertex 1")
1479          self.failUnless( segs[1].size == 3, "seg 1 has wrong size.")
1480          self.failUnless( numpy.linalg.norm(segs[1]-[21.547005383792515,21.547005383792515, -11.547005383792515]) < self.EPS, "wrong vertex. 1 ")
1481          self.failUnless( isinstance(segs[2], numpy.ndarray), "wrong class of vertex 2")
1482          self.failUnless( segs[2].size == 3, "seg 2 has wrong size.")
1483          self.failUnless( numpy.linalg.norm(segs[2]-[0., 24.142135623730951, -14.142135623730951]) < self.EPS, "wrong vertex. 2 ")
1484          self.failUnless( abs(0.-f.getW0Range(1)[0]) <=self.EPS," wrong W0 range (0)")
1485          self.failUnless( abs(31.857329272664341-f.getW0Range(1)[1]) <=self.EPS," wrong W0 range (1)")
1486          self.failUnless( abs(-20. - f.getW1Range(1)[0]) <=self.EPS," wrong W1 range (0)")
1487          self.failUnless( abs(0. - f.getW1Range(1)[1]) <=self.EPS," wrong W1 range (1)")
1488          self.failUnless( abs(0.0-f.getW0Offsets(1)[0])<=self.EPS," wrong W0 offsets (0)")
1489          self.failUnless( abs(15.92866463633217-f.getW0Offsets(1)[1])<=self.EPS," wrong W0 offsets (1)")
1490          self.failUnless( abs(31.857329272664341-f.getW0Offsets(1)[2])<=self.EPS," wrong W0 offsets(2)")
1491          #
1492          #    ============ fresh start ====================
1493          #
1494          f.addFault(V0=[1.,0,0.],strikes=[pi/2, pi],ls=[1.,1.], dips=pi/2,depths=20,tag=1)
1495          f.addFault(V0=[10.,0,0],strikes=[3.*pi/4],ls=[14.142135623730951], tag=2, w0_offsets=[0,20], w1_max=20, dips=pi/2,depths=20)
1496          c=f.getCenterOnSurface()
1497          self.failUnless( isinstance(c, numpy.ndarray), "center has wrong class")
1498          self.failUnless( c.size == 3, "center size is wrong")
1499          self.failUnless( numpy.linalg.norm(c-[12./5.,12./5.,0.]) < self.EPS, "center has wrong coordinates.")
1500          o=f.getOrientationOnSurface()/pi*180.
1501          self.failUnless( abs(o+45.) < self.EPS, "wrong orientation.")
1502
1503          f.transform(rot=-pi/2., shift=[-1.,-1.,0.])
1504          self.failUnless( [ 1, 2 ] == f.getTags(), "tags after transformation wrong")
1505          self.failUnless(  2. == f.getTotalLength(1), "length after transformation wrong")
1506          self.failUnless(  20. == f.getMediumDepth(1), "depth after transformation wrong")
1507          rw0=f.getW0Range(1)
1508          self.failUnless( len(rw0) ==2, "wo range has wrong length")
1509          self.failUnless( abs(rw0[0]) < self.EPS,"W0 0 wrong.")
1510          self.failUnless( abs(rw0[1]-2.) < self.EPS,"W0 1 wrong.")
1511          self.failUnless( (-20., 0.) ==  f.getW1Range(1)," wrong W1 rangeafter transformation ")
1512          dips=f.getDips(1)
1513          self.failUnless(len(dips) == 2, "wrong number of dips.")
1514          self.failUnless( abs(dips[0]-1.5707963267948966) <= self.EPS, "wrong dip")
1515          self.failUnless( abs(dips[1]-1.5707963267948966) <= self.EPS, "wrong dip")
1516          ds=f.getDepths(1)
1517          self.failUnless( len(ds) == 3, "wrong number of depth")
1518          self.failUnless( abs(ds[0]-20.) < self.EPS, "wrong depth at vertex 0 ")
1519          self.failUnless( abs(ds[1]-20.) < self.EPS, "wrong depth at vertex 1 ")
1520          self.failUnless( abs(ds[2]-20.) < self.EPS, "wrong depth at vertex 1 ")
1521          segs=f.getTopPolyline(1)
1522          self.failUnless( len(segs) == 3, "wrong number of segmentsafter transformation ")
1523          self.failUnless( isinstance(segs[0], numpy.ndarray), "wrong class of vertex 0 after transformation")
1524          self.failUnless( segs[0].size == 3, "seg 0 has wrong size after transformation.")
1525          self.failUnless( numpy.linalg.norm(segs[0]-[-1.,0.,0.]) < self.EPS, "wrong vertex. 0  after transformation")
1526          self.failUnless( isinstance(segs[1], numpy.ndarray), "wrong class of vertex  after transformation1")
1527          self.failUnless( segs[1].size == 3, "seg 1 has wrong size after transformation.")
1528          self.failUnless( numpy.linalg.norm(segs[1]-[0.,0.,0.]) < self.EPS, "wrong vertex.  after transformation1 ")
1529          self.failUnless( isinstance(segs[2], numpy.ndarray), "wrong class of vertex  after transformation2")
1530          self.failUnless( segs[2].size == 3, "seg 2 has wrong size after transformation.")
1531          self.failUnless( numpy.linalg.norm(segs[2]-[0., 1.,0.]) < self.EPS, "wrong vertex after transformation. 2 ")
1532          self.failUnless(  abs(f.getTotalLength(2)-14.1421356237) < self.EPS * 14.1421356237, "wrong length after transformation")
1533          self.failUnless(  20. == f.getMediumDepth(2), "depth wrong after transformation")
1534          rw0=f.getW0Range(2)
1535          self.failUnless( len(rw0) ==2, "wo range has wrong length")
1536          self.failUnless( abs(rw0[0]) < self.EPS,"W0 0 wrong.")
1537          self.failUnless( abs(rw0[1]-20.) < self.EPS,"W0 1 wrong.")
1538          self.failUnless( (-20., 0.) ==  f.getW1Range(2)," wrong W1 range after transformation")
1539          self.failUnless( [0., 20.] ==  f.getW0Offsets(2)," wrong W0 offsets after transformation")
1540          dips=f.getDips(2)
1541          self.failUnless(len(dips) == 1, "wrong number of dips.")
1542          self.failUnless( abs(dips[0]-1.5707963267948966) <= self.EPS, "wrong dip")
1543          ds=f.getDepths(2)
1544          self.failUnless( len(ds) == 2, "wrong number of depth")
1545          self.failUnless( abs(ds[0]-20.) < self.EPS, "wrong depth at vertex 0 ")
1546          self.failUnless( abs(ds[1]-20.) < self.EPS, "wrong depth at vertex 1 ")
1547          segs=f.getTopPolyline(2)
1548          self.failUnless( len(segs) == 2, "wrong number of segments after transformation")
1549          self.failUnless( isinstance(segs[0], numpy.ndarray), "wrong class of vertex 0 after transformation")
1550          self.failUnless( numpy.linalg.norm(segs[0]-[-1.,-9,0.]) < self.EPS, "wrong vertex. 0  after transformation")
1551          self.failUnless( isinstance(segs[1], numpy.ndarray), "wrong class of vertex 1 after transformation")
1552          self.failUnless( numpy.linalg.norm(segs[1]-[9.,1.,0.]) < self.EPS, "wrong vertex. 1  after transformation")
1553          #
1554          #    ============ fresh start ====================
1555          #
1556          f=FaultSystem(dim=3)
1557
1558          top1=[ [0.,0.,0.], [1., 0., 0.] ]
1559          f.addFault(V0=[0.,0,0],strikes=[0.],ls=[1.,], dips=pi/2, depths=1.,tag=1)
1560          top1=[ [10.,0.,0], [10.,10.,0], [0.,10.,0] ]
1561          f.addFault(V0=[10.,0.,0.],strikes=[pi/2, pi],ls=[10.,10.],tag=2, dips=pi/4, depths=20.)
1562
1563          p,m=f.getParametrization([0.3,0.,-0.5],1)
1564          self.failUnless(length(p-[0.3,-0.5]) <= self.EPS, "wrong value.")
1565          self.failUnless(m==1., "wrong value.")
1566
1567          p,m=f.getParametrization([0.5,0.,-0.5],1)
1568          self.failUnless(length(p-[0.5,-0.5]) <= self.EPS, "wrong value.")
1569          self.failUnless(m==1., "wrong value.")
1570
1571          p,m=f.getParametrization([0.25,0.,-0.5],1)
1572          self.failUnless(length(p-[0.25,-0.5]) <= self.EPS, "wrong value.")
1573          self.failUnless(m==1., "wrong value.")
1574
1575          p,m=f.getParametrization([0.5,0.,-0.25],1)
1576          self.failUnless(length(p-[0.5,-0.25]) <= self.EPS, "wrong value.")
1577          self.failUnless(m==1., "wrong value.")
1578
1579          p,m=f.getParametrization([0.001,0.,-0.001],1)
1580          self.failUnless(length(p-[0.001, -0.001]) <= self.EPS, "wrong value.")
1581          self.failUnless(m==1., "wrong value.")
1582
1583          p,m=f.getParametrization([0.001,0.,0.001],1)
1584          self.failUnless(m==0., "wrong value.")
1585
1586          p,m=f.getParametrization([0.999,0.,0.001],1)
1587          self.failUnless(m==0., "wrong value.")
1588
1589          p,m=f.getParametrization([1.001,0.,-0.001],1)
1590          self.failUnless(m==0., "wrong value.")
1591          p,m=f.getParametrization([1.001,0.,-0.1],1)
1592          self.failUnless(m==0., "wrong value.")
1593          p,m=f.getParametrization([1.001,0.,-0.000000001],1)
1594          self.failUnless(m==0., "wrong value.")
1595
1596          p,m=f.getParametrization([0.999,0.,-0.001],1)
1597          self.failUnless(length(p-[0.999, -0.001]) <= self.EPS, "wrong value.")
1598          self.failUnless(m==1., "wrong value.")
1599
1600          p,m=f.getParametrization([ 16.29252873 , 6.46410161 ,-6.29252873], 2, tol=1.e-7)
1601          self.failUnless(m==1., "wrong value.")
1602          self.failUnless(length(p-[4.7785993908996511, -10]) <= self.EPS*10., "wrong value.")
1603          p,m=f.getParametrization([15.77350269, 12.77350269, -5.77350269], 2, tol=1.e-7)
1604          self.failUnless(m==1., "wrong value.")
1605          self.failUnless(length(p-[11.150065245432518, -10]) <= self.EPS*10., "wrong value.")
1606
1607          p,m=f.getParametrization([  3., 17.0710678, -7.0710678], 2, tol=1.e-7)
1608          self.failUnless(m==1., "wrong value.")
1609          self.failUnless(length(p-[27.078729881764687, -10]) <= self.EPS*10., "wrong value.")
1610          p,m=f.getParametrization([9.30940108, 16.55204176, -6.55204176], 2, tol=1.e-7)
1611          self.failUnless(m==1., "wrong value.")
1612          self.failUnless(length(p-[20.707264027231822, -10]) <= self.EPS*10., "wrong value.")
1613
1614          p,m=f.getParametrization([ 21.54700538,  21.54700538, -11.54700538], 2, tol=1.e-7)
1615          self.failUnless(m==1., "wrong value.")
1616          self.failUnless(length(p-[15.92866463633217, -20]) <= self.EPS*10., "wrong value.")
1617
1618          p,m=f.getParametrization([ 0.,0.,0.], 2, tol=1.e-7)
1619          self.failUnless(m==0., "wrong value.")
1620
1621          p,m=f.getParametrization([ 11.,11.,0.], 2, tol=1.e-7)
1622          self.failUnless(m==0., "wrong value.")
1623
1624
1625          s,d=f.getSideAndDistance([0.,-1.,0.], tag=1)
1626          self.failUnless( s>0, "wrong side.")
1627          self.failUnless( abs(d-1.)<self.EPS, "wrong distance.")
1628          s,d=f.getSideAndDistance([1.,-1.,0.], tag=1)
1629          self.failUnless( s>0, "wrong side.")
1630          self.failUnless( abs(d-1.)<self.EPS, "wrong distance.")
1631          s,d=f.getSideAndDistance([0.,1.,0.], tag=1)
1632          self.failUnless( s<0, "wrong side.")
1633          self.failUnless( abs(d-1.)<self.EPS, "wrong distance.")
1634          s,d=f.getSideAndDistance([1.,1.,0.], tag=1)
1635          self.failUnless( s<0, "wrong side.")
1636          self.failUnless( abs(d-1.)<self.EPS, "wrong distance.")
1637
1638
1639          s,d=f.getSideAndDistance([0.,0.,0.], tag=2)
1640          self.failUnless( s<0, "wrong side.")
1641          self.failUnless( abs(d-10.)<self.EPS, "wrong distance.")
1642          s,d=f.getSideAndDistance([5.,5.,0.], tag=2)
1643          self.failUnless( s<0, "wrong side.")
1644          self.failUnless( abs(d-5.)<self.EPS, "wrong distance.")
1645
1646          s,d=f.getSideAndDistance([10.,10.,-1.], tag=2)
1647          self.failUnless( s<0, "wrong side.")
1648          self.failUnless( abs(d-0.70710678118654757)<self.EPS, "wrong distance.")
1649          s,d=f.getSideAndDistance([10.,10.,-2.], tag=2)
1650          self.failUnless( s<0, "wrong side.")
1651          self.failUnless( abs(d-2.*0.70710678118654757)<self.EPS, "wrong distance.")
1652          s,d=f.getSideAndDistance([10.,10.,-3.], tag=2)
1653          self.failUnless( s<0, "wrong side.")
1654          self.failUnless( abs(d-3.*0.70710678118654757)<self.EPS, "wrong distance.")
1655
1656          s,d=f.getSideAndDistance([5.,12.,0], tag=2)
1657          self.failUnless( s>0, "wrong side.")
1658          self.failUnless( abs(d-2*0.70710678118654757)<self.EPS, "wrong distance.")
1659          s,d=f.getSideAndDistance([5.,12.,-1], tag=2)
1660          self.failUnless( s>0, "wrong side.")
1661          self.failUnless( abs(d-0.70710678118654757)<self.EPS, "wrong distance.")
1662          s,d=f.getSideAndDistance([5.,12.,-2], tag=2)
1663          # s not checked as it is undefined.
1664          self.failUnless( abs(d)<self.EPS, "wrong distance.")
1665          s,d=f.getSideAndDistance([5.,12.,-3], tag=2)
1666          self.failUnless( s<0, "wrong side.")
1667          self.failUnless( abs(d-0.70710678118654757)<self.EPS, "wrong distance.")
1668          s,d=f.getSideAndDistance([5.,12.,-4], tag=2)
1669          self.failUnless( s<0, "wrong side.")
1670          self.failUnless( abs(d-2.*0.70710678118654757)<self.EPS, "wrong distance.")
1671
1672  if __name__ == '__main__':  if __name__ == '__main__':
1673     suite = unittest.TestSuite()     suite = unittest.TestSuite()

Legend:
 Removed from v.2654 changed lines Added in v.2663

 ViewVC Help Powered by ViewVC 1.1.26