diff --git a/LoadCase/Interaction.py b/LoadCase/Interaction.py index 70babc74a1560a8fb57245d7ff035fd123e34fbd..b912a85135985802e90490ecdce66520b3c5ba88 100644 --- a/LoadCase/Interaction.py +++ b/LoadCase/Interaction.py @@ -44,7 +44,12 @@ def CoupleIpMTsToSring(**kwargs): # Create an associated region by id region1 = a.Set(referencePoints=(r1[RP.id], ), name='ipMTsRP') # Define a collection of ipMT edges to be assigned coupling connection - combinedEdges = sum_regions('edge', 'ipMTnames', separate='False', **kwargs) + combinedEdges = sum_regions( + verts_index='None', + regionType='edge', + collectionName='ipMTnames', + separate='False', + **kwargs) region2 = a.Set(edges=combinedEdges, name='ipMT-set') # Create a coupling constraint between region 1 and region 2 influenceRadius = WHOLE_SURFACE @@ -59,35 +64,68 @@ def CoupleIpMTsToSring(**kwargs): def CoupleIpMTsToCentrosomes(**kwargs): """ - connect and couple interpolar microtubules with centrosomes + connect and couple interpolar microtubules to centrosomes :param kwargs: object :return: None """ # Provide coupling constraint parameters - influenceRadius = 0.1 + influenceRadius = WHOLE_SURFACE couplingType = DISTRIBUTING - weightingMethod = UNIFORM - - # Select all ipMT - combined_region_right, combined_region_left = \ - sum_regions('vertice', 'ipMTnames', separate='True', **kwargs) - # Couple right ipMTs to the right centrosome + weightingMethod = LINEAR a = return_assembly(**kwargs) - region2Right = a.Set(vertices=combined_region_right, name='ipMT-set-right') - print(region2Right) - region1 = pick_region('centrosome', 'centrosome', 'centrosome-right', **kwargs) - print(region1) - # Coupling region name - name = 'ipMT-centrosome-coupling-right' - coupling_constraint(region2Right, region1, influenceRadius, couplingType, - weightingMethod, name, **kwargs) - # Couple left ipMTs to the left centrosome - region2Left = a.Set(vertices=combined_region_left, name='ipMT-set-left') - region1 = pick_region('centrosome', 'centrosome', 'centrosome-left', **kwargs) + for index, instance in enumerate(a.instances.keys()): + if 'ipMT' in instance and 'connector' not in instance: + vert = a.instances[instance].vertices[0].pointOn + masterPoint = a.instances[instance].vertices.findAt(vert, ) + masterRegion = a.Set(vertices=masterPoint, name='master-' + instance) + if index % 2 == 0: + s1 = a.instances['centrosome-right'].faces + side1Faces1 = s1.getSequenceFromMask(mask=('[#1 ]',), ) + slaveRegion = a.Surface(side1Faces=side1Faces1, name='RightCentrosomeTo' + instance + 'coupling') + else: + s1 = a.instances['centrosome-left'].faces + side1Faces1 = s1.getSequenceFromMask(mask=('[#1 ]',), ) + slaveRegion = a.Surface(side1Faces=side1Faces1, name='LeftCentrosomeTo' + instance + 'coupling') + coupling_constraint(region1=masterRegion, + region2=slaveRegion, + influenceRadius=influenceRadius, + couplingType=couplingType, + weightingMethod=weightingMethod, + name=instance + 'toCentrosomeCoupling', + **kwargs) + # Select all ipMT + # combined_region_right, combined_region_left = \ + # sum_regions( + # verts_index='None', + # regionType='vertice', + # collectionName='ipMTnames', + # separate='True', + # **kwargs) + # # Couple right ipMTs to the right centrosome + # a = return_assembly(**kwargs) + # region2Right = a.Set(vertices=combined_region_right, name='ipMT-set-right') + # region1 = pick_region( + # verts_index='None', + # regionType='centrosome', + # collectionName='centrosome', + # position='centrosome-right', + # **kwargs) + # # Coupling region name + # name = 'ipMT-centrosome-coupling-right' + # coupling_constraint(region2Right, region1, influenceRadius, couplingType, + # weightingMethod, name, **kwargs) + # # Couple left ipMTs to the left centrosome + # region2Left = a.Set(vertices=combined_region_left, name='ipMT-set-left') + # region1 = pick_region( + # verts_index='None', + # regionType='centrosome', + # collectionName='centrosome', + # position='centrosome-left', + # **kwargs) # Coupling region name - name = 'ipMT-centrosome-coupling-left' - coupling_constraint(region2Left, region1, influenceRadius, couplingType, - weightingMethod, name, **kwargs) + # name = 'ipMT-centrosome-coupling-left' + # coupling_constraint(region2Left, region1, influenceRadius, couplingType, + # weightingMethod, name, **kwargs) def CoupleAMTs(**kwargs): @@ -131,27 +169,65 @@ def CoupleAMTsToCentrosomes(**kwargs): :return: None """ # parametyers - influenceRadius = 0.1 - couplingType = STRUCTURAL - weightingMethod = UNIFORM + influenceRadius = WHOLE_SURFACE + couplingType = DISTRIBUTING + weightingMethod = LINEAR + a = return_assembly(**kwargs) + for index, instance in enumerate(a.instances.keys()): + if 'aMT' in instance: + + vert = a.instances[instance].vertices[0].pointOn + masterPoint = a.instances[instance].vertices.findAt(vert,) + masterRegion = a.Set(vertices=masterPoint, name='master-'+instance) + if index % 2 == 0: + s1 = a.instances['centrosome-right'].faces + side1Faces1 = s1.getSequenceFromMask(mask=('[#1 ]',), ) + slaveRegion = a.Surface(side1Faces=side1Faces1, name='RightCentrosomeTo'+instance+'coupling') + else: + s1 = a.instances['centrosome-left'].faces + side1Faces1 = s1.getSequenceFromMask(mask=('[#1 ]',), ) + slaveRegion = a.Surface(side1Faces=side1Faces1, name='LeftCentrosomeTo' + instance + 'coupling') + + coupling_constraint(region1=masterRegion, + region2=slaveRegion, + influenceRadius=influenceRadius, + couplingType=couplingType, + weightingMethod=weightingMethod, + name=instance+'toCentrosomeCoupling', + **kwargs) + # Return all aMTs gathered in right end left regions - vertsRightSum, vertsLeftSum = sum_regions( - regionType='vertice', collectionName='aMTnames', separate='True', **kwargs) - # Right aMTs: - a = AddComponents.return_assembly(**kwargs) - region1 = a.Set(vertices=vertsRightSum, name='aMTcouplingRightSet') - # Right Centrosome slave region - region2 = pick_region('centrosome', 'centrosome', 'centrosome-right', **kwargs) - # Couple 2 regions - coupling_constraint(region1, region2, influenceRadius, couplingType, - weightingMethod, 'RightAMTtoCentrosomeCoupling', **kwargs) - # Left aMTs: - region1 = a.Set(vertices=vertsLeftSum, name='aMTcouplingLeftSet') - # Left Centrosome slave region - region2 = pick_region('centrosome', 'centrosome', 'centrosome-left', **kwargs) - # Couple 2 regions - coupling_constraint(region1, region2, influenceRadius, couplingType, - weightingMethod, 'LeftAMTtoCentrosomeCoupling', **kwargs) + # vertsRightSum, vertsLeftSum = sum_regions( + # verts_index=0, + # regionType='vertice', + # collectionName='aMTnames', + # separate='True', + # **kwargs) + # # Right aMTs: + # a = AddComponents.return_assembly(**kwargs) + # region1 = a.Set(vertices=vertsRightSum, name='aMTcouplingRightSet') + # # Right Centrosome slave region + # region2 = pick_region( + # verts_index='None', + # regionType='centrosome', + # collectionName='centrosome', + # position='centrosome-right', + # **kwargs) + # # Couple 2 regions + # coupling_constraint(region1, region2, influenceRadius, couplingType, + # weightingMethod, 'RightAMTtoCentrosomeCoupling', **kwargs) + # # Left aMTs: + # region1 = a.Set(vertices=vertsLeftSum, name='aMTcouplingLeftSet') + # # Left Centrosome slave region + # region2 = pick_region( + # verts_index='None', + # regionType='centrosome', + # collectionName='centrosome', + # position='centrosome-left', + # **kwargs) + # # Couple 2 regions + # coupling_constraint(region1, region2, influenceRadius, couplingType, + # weightingMethod, 'LeftAMTtoCentrosomeCoupling', **kwargs) ''' Testing ''' diff --git a/LoadCase/InteractionHelpers.py b/LoadCase/InteractionHelpers.py index 66991ec0a60ca638c349da65ecfb6508c9b74e21..e5bf9eaf5c50dbb2c63b9c3028efe29c0f387e53 100644 --- a/LoadCase/InteractionHelpers.py +++ b/LoadCase/InteractionHelpers.py @@ -27,7 +27,7 @@ def create_RP(**kwargs): return RP -def pick_region(regionType, collectionName, position, **kwargs): +def pick_region(verts_index, regionType, collectionName, position, **kwargs): """ pick a region to assign connection :param regionType: 'vertice', 'edge', 'centrosome' -> defines the type of the picked region @@ -40,9 +40,14 @@ def pick_region(regionType, collectionName, position, **kwargs): # Create region from specified vertices if regionType == 'vertice': collection = kwargs[collectionName] - verts = [a.instances[vI].vertices - for vI in a.instances.keys() if vI in collection] - region = verts + if verts_index == 0: + verts = [a.instances[vI].vertices[verts_index] + for vI in a.instances.keys() if vI in collection] + region = verts + else: + verts = [a.instances[vI].vertices + for vI in a.instances.keys() if vI in collection] + region = verts # Create region from specified edges elif regionType == 'edge': collection = kwargs[collectionName] @@ -65,7 +70,7 @@ def pick_region(regionType, collectionName, position, **kwargs): return region -def sum_regions(regionType, collectionName, separate='True', **kwargs): +def sum_regions(verts_index, regionType, collectionName, separate='True', **kwargs): """ split a single picked region into a collection of sub-regions :param regionType: 'vertice', 'edge', 'centrosome' -> defines the type of the picked region @@ -75,7 +80,7 @@ def sum_regions(regionType, collectionName, separate='True', **kwargs): :return: either combined_region or combined_region_right and combined_region_left """ # select a master region - region = pick_region(regionType, collectionName, 'False', **kwargs) + region = pick_region(verts_index, regionType, collectionName, 'False', **kwargs) # separate sub-regions into right and left ones if separate == 'True': combined_region_right = region[0] diff --git a/LoadCase/Step.py b/LoadCase/Step.py index a3cde5ff6f6ceb8b791107469aaf51af9d57e28d..3f9653e82c447d1230c58e1d6c8c34ab29d5a448 100644 --- a/LoadCase/Step.py +++ b/LoadCase/Step.py @@ -34,6 +34,8 @@ def Step(**kwargs): mdb.models['test'].FieldOutputRequest( name='output', createStepName=StepName, variables=( - 'E', 'VE', 'PE', 'VEEQ', 'PEEQ', 'PEEQT', 'PEEQMAX', - 'PEMAG', 'PEQC', 'EE', 'IE', 'THE', 'NE', 'LE', 'ER', 'SE', 'SPE', - 'SEPE', 'SEE', 'SEP', 'SALPHA', 'ENER', 'ELEN', 'ELEDEN')) + 'S', 'MISES', 'MISESMAX', 'TSHR', 'CTSHR', 'ALPHA', 'TRIAX', 'VS', 'PS', + 'CS11', 'SSAVG', 'MISESONLY', 'PRESSONLY', 'E', 'VE', 'PE', 'VEEQ', 'PEEQ', + 'PEEQT', 'PEEQMAX', 'PEMAG', 'PEQC', 'EE', 'IE', 'THE', 'NE', 'LE', 'ER', + 'SE', 'SPE', 'SEPE', 'SEE', 'SEP', 'SALPHA', 'U', 'ENER', 'ELEN', + 'ELEDEN')) diff --git a/SpindleAssembly/PositionConnectors.py b/SpindleAssembly/PositionConnectors.py index ac388dab020ecc1cb3c6dc89e1c1622cda71048d..c1838e7d326d9ef3eb5b1a1637d35a3b74a07d24 100644 --- a/SpindleAssembly/PositionConnectors.py +++ b/SpindleAssembly/PositionConnectors.py @@ -111,9 +111,10 @@ def pick_vertices(mtname, data, **kwargs): connector_data = [] for sublist in data: if mtname == sublist[0]: - connector_data.append([a.instances[sublist[1]].vertices[sublist[3]], + connector_data.append([a.instances[sublist[1]].vertices, sublist[3], - a.instances[sublist[1]].vertices[sublist[3]].pointOn]) + a.instances[sublist[1]].vertices[sublist[3]].pointOn, + sublist[1]]) # Sort connectors by position if int(mtname[-1]) % 2 == 0: # if ipMT is right @@ -124,6 +125,39 @@ def pick_vertices(mtname, data, **kwargs): return connector_data +# def attach_connectors(data, **kwargs): +# """ +# Creates attachment wire between two vertexes and defined the properties of connection +# :param data: list containing all ipMTs and connectors of the model +# :param kwargs: dictionary -> keyword arguments +# :return: Null +# """ +# a = return_assembly(**kwargs) +# a.regenerate() +# # Create connector section +# modelname = kwargs['modelname'] +# mdb.models[modelname].ConnectorSection(name='ConnSect', assembledType=BEAM) +# # Iterate through unique ipMT names +# mt_names = [sublist[0] for sublist in data] +# mt_names = set(mt_names) +# for mtname in mt_names: +# # Return all connectors associated with the current ipMT +# connector_data = pick_vertices( +# mtname, data, **kwargs) +# # Return all points on the current ipMT +# mtdata = a.instances[mtname].vertices +# # Link points of ipMT with connector ends +# for index, vertex in enumerate(mtdata[1:-1]): +# a.WirePolyLine( +# points=((vertex, connector_data[index][0]),), +# mergeType=IMPRINT, meshable=False) +# e1 = a.edges +# edges1 = e1.getSequenceFromMask(mask=('[#1 ]',), ) +# a.Set(edges=edges1, name='Wire-' + mtname + str(index)) +# region1 = mdb.models[modelname].rootAssembly.sets['Wire-' + mtname + str(index)] +# csa = a.SectionAssignment(sectionName='ConnSect', region=region1) + + def attach_connectors(data, **kwargs): """ Creates attachment wire between two vertexes and defined the properties of connection @@ -135,23 +169,38 @@ def attach_connectors(data, **kwargs): a.regenerate() # Create connector section modelname = kwargs['modelname'] - mdb.models[modelname].ConnectorSection(name='ConnSect', assembledType=BEAM) + # Iterate through unique ipMT names mt_names = [sublist[0] for sublist in data] mt_names = set(mt_names) for mtname in mt_names: - # Return all connectors associated with the current ipMT - connector_data = pick_vertices( - mtname, data, **kwargs) - # Return all points on the current ipMT - mtdata = a.instances[mtname].vertices - # Link points of ipMT with connector ends - for index, vertex in enumerate(mtdata[1:-1]): - a.WirePolyLine( - points=((vertex, connector_data[index][0]),), - mergeType=IMPRINT, meshable=False) - e1 = a.edges - edges1 = e1.getSequenceFromMask(mask=('[#1 ]',), ) - a.Set(edges=edges1, name='Wire-' + mtname + str(index)) - region1 = mdb.models[modelname].rootAssembly.sets['Wire-' + mtname + str(index)] - csa = a.SectionAssignment(sectionName='ConnSect', region=region1) + for sublist in data: + if mtname == sublist[0]: + connector_end = sublist[3] + connector_name = sublist[1] + + # Link points of ipMT with connector ends + end = a.instances[connector_name].vertices[connector_end].pointOn + masterPoint = a.instances[connector_name].vertices.findAt(end,) + masterName = 'master-'+connector_name+'-'+str(connector_end) + masterRegion = a.Set(vertices=masterPoint, + name=masterName) + slaveEdge = a.instances[mtname].edges + slaveName = 'slave-'+mtname + slaveRegion = a.Set(edges=slaveEdge, name=slaveName) + mdb.models[modelname].Coupling(name=masterName+slaveName, + controlPoint=masterRegion, + surface=slaveRegion, + influenceRadius=0.2, + couplingType=DISTRIBUTING, + weightingMethod=LINEAR, + localCsys=None, u1=ON, u2=ON, ur3=ON, + adjust=False) + # a.WirePolyLine( + # points=((vertex, connector_data[index][0]),), + # mergeType=IMPRINT, meshable=False) + # e1 = a.edges + # edges1 = e1.getSequenceFromMask(mask=('[#1 ]',), ) + # a.Set(edges=edges1, name='Wire-' + mtname + str(index)) + # region1 = mdb.models[modelname].rootAssembly.sets['Wire-' + mtname + str(index)] + # csa = a.SectionAssignment(sectionName='ConnSect', region=region1) \ No newline at end of file diff --git a/SpindleAssembly/assembly_random.py b/SpindleAssembly/assembly_random.py index fa13670cd7d571cbd45af7384c254be5007d4734..cd4c7ef1b8a1f0f18e605a888bce1b4b8afe5d4b 100644 --- a/SpindleAssembly/assembly_random.py +++ b/SpindleAssembly/assembly_random.py @@ -78,6 +78,13 @@ def add_and_position_astral_mts(**kwargs): def assign_ipMTs(**kwargs): + """ + + :param kwargs: + :type kwargs: + :return: + :rtype: + """ # Create dictionary to store MT metadata MTdata = {'MTnames': [], 'MTpositions': [], @@ -225,7 +232,7 @@ def assign_ipMTs(**kwargs): kwargs = {'x' : 0, 'y': 0, 'index': 0, 'modelname': 'test', 'assembly': 0, 'CentrosomeRadius': 0.06, - 'CentrosomeLength': 0.12, 'CentrosomeE': 1500000000.0, 'CentrosomeNu': 0.3, 'ipMTnumber': 6, + 'CentrosomeLength': 0.12, 'CentrosomeE': 1500000000.0, 'CentrosomeNu': 0.3, 'ipMTnumber': 2, 'lengthInterval' : [2, 6], 'r1': 0.015, 'r2': 0.025, 'ElasticModulus': 1500000000.0, 'PoissonRatio': 0.3, 'spindleLength' : 10, 'Nconnectors': 5, 'connectorRadius': 0.005, 'connectorE': 1500000000., 'connectorNu' : 0.3, 'aMTnumber': 50, 'aMTlength': 2, 'springStiffness': 10,