Skip to content

Commit

Permalink
continued viewer migration
Browse files Browse the repository at this point in the history
  • Loading branch information
tomvanmele committed Oct 21, 2024
1 parent fe157e8 commit 3fbb019
Show file tree
Hide file tree
Showing 42 changed files with 117 additions and 418 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added

### Changed
* Migrate from compas_view2 to compas_viewer

* Changed compas_view2 to compas_viewer.
* Changed sample files to COMPAS 2 format.
* Fixed bug in temp viewer arrow solution.

### Removed

* Removed `matplotlib` from env files.
* Removed `pip` requirements.


## [0.4.0] 2024-03-02

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@
from compas_cra.equilibrium import cra_solve
from compas_cra.viewers import cra_view

# convert to COMPAS 2 data format
FILE_I = os.path.join(compas_cra.SAMPLE, "cubes.json")

assembly = compas.json_load(FILE_I)
assembly = assembly.copy(cls=CRA_Assembly)
assembly: CRA_Assembly = assembly.copy(cls=CRA_Assembly)
assembly.set_boundary_conditions([0])

assembly_interfaces_numpy(assembly, nmax=10, amin=1e-2, tmax=1e-2)

cra_solve(assembly, verbose=True, timer=True)

cra_view(
assembly,
resultant=False,
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@
if axis == "xy30-axis":
rotate_axis = [mt.sqrt(3), 1, 0] # rotate around xy30-axis

# conver to COMPAS 2 data format
assembly = compas.json_load(FILE_I)
assembly = assembly.copy(cls=CRA_Assembly)
assembly: CRA_Assembly = assembly.copy(cls=CRA_Assembly)
assembly.set_boundary_conditions([0, 1])

assembly_interfaces_numpy(assembly, nmax=10, amin=1e-2, tmax=1e-2)
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions docs/examples/07_shelf.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import os

import compas

import compas_cra
from compas_cra.algorithms import assembly_interfaces_numpy
from compas_cra.datastructures import CRA_Assembly
Expand Down
7 changes: 4 additions & 3 deletions docs/examples/08_snake.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import os

import compas

import compas_cra
from compas_cra.algorithms import assembly_interfaces_numpy
from compas_cra.datastructures import CRA_Assembly
Expand All @@ -18,7 +19,7 @@
FILE_I = os.path.join(compas_cra.SAMPLE, "snake.json")

assembly = compas.json_load(FILE_I)
assembly = assembly.copy(cls=CRA_Assembly)
assembly: CRA_Assembly = assembly.copy(cls=CRA_Assembly)

assembly.set_boundary_conditions([0])
# assembly.delete_node(1)
Expand All @@ -27,8 +28,8 @@

assembly_interfaces_numpy(assembly, amin=1e-4, tmax=1e-2)

cra_solve(assembly, verbose=True, density=d, d_bnd=dispbnd, eps=overlap, mu=mu)
# cra_penalty_solve(assembly, verbose=True, density=d, d_bnd=dispbnd, eps=overlap, mu=mu)
# cra_solve(assembly, verbose=True, density=d, d_bnd=dispbnd, eps=overlap, mu=mu)
cra_penalty_solve(assembly, verbose=True, density=d, d_bnd=dispbnd, eps=overlap, mu=mu)
cra_view(
assembly,
resultant=True,
Expand Down
11 changes: 6 additions & 5 deletions docs/examples/09_bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import os

import compas

import compas_cra
from compas_cra.algorithms import assembly_interfaces_numpy
from compas_cra.datastructures import CRA_Assembly
Expand All @@ -19,19 +20,19 @@
FILE_I = os.path.join(compas_cra.SAMPLE, "bridge.json")

assembly = compas.json_load(FILE_I)
assembly = assembly.copy(cls=CRA_Assembly)
assembly: CRA_Assembly = assembly.copy(cls=CRA_Assembly)
assembly.set_boundary_conditions([0, 1])

density = {node: 3.51 if node in [11, 12, 13, 14, 15] else 1 for node in assembly.graph.nodes()}
density_setup(assembly, density)

assembly.delete_blocks([3, 4, 5, 6, 7, 8, 9, 10])
assembly.delete_blocks([11, 12, 13, 14, 15])
# assembly.delete_blocks([3, 4, 5, 6, 7, 8, 9, 10])
# assembly.delete_blocks([11, 12, 13, 14, 15])

assembly_interfaces_numpy(assembly, amin=1e-6, tmax=1e-4)

cra_solve(assembly, verbose=True, density=d, d_bnd=dispbnd, eps=overlap, mu=mu)
# cra_penalty_solve(assembly, verbose=True, density=d, d_bnd=dispbnd, eps=overlap, mu=mu)
# cra_solve(assembly, verbose=True, density=d, d_bnd=dispbnd, eps=overlap, mu=mu)
cra_penalty_solve(assembly, verbose=True, density=d, d_bnd=dispbnd, eps=overlap, mu=mu)
cra_view(
assembly,
resultant=True,
Expand Down
1 change: 1 addition & 0 deletions docs/examples/10_armadillo.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import os

import compas

import compas_cra
from compas_cra.algorithms import assembly_interfaces_numpy
from compas_cra.viewers import cra_view
Expand Down
3 changes: 2 additions & 1 deletion docs/examples/11_concave-short.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import os

import compas

import compas_cra
from compas_cra.datastructures import CRA_Assembly
from compas_cra.equilibrium import cra_solve
Expand All @@ -16,7 +17,7 @@
FILE_I = os.path.join(compas_cra.SAMPLE, "concave-short.json")

assembly = compas.json_load(FILE_I)
assembly = assembly.copy(cls=CRA_Assembly)
assembly: CRA_Assembly = assembly.copy(cls=CRA_Assembly)
assembly.set_boundary_conditions([0])

assembly.rotate_assembly([0, 0, 0], rotate_axis, deg)
Expand Down
3 changes: 2 additions & 1 deletion docs/examples/12_concave-long.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import os

import compas

import compas_cra
from compas_cra.datastructures import CRA_Assembly
from compas_cra.equilibrium import cra_solve
Expand All @@ -16,7 +17,7 @@
FILE_I = os.path.join(compas_cra.SAMPLE, "concave-long.json")

assembly = compas.json_load(FILE_I)
assembly = assembly.copy(cls=CRA_Assembly)
assembly: CRA_Assembly = assembly.copy(cls=CRA_Assembly)
assembly.set_boundary_conditions([0])

assembly.rotate_assembly([0, 0, 0], rotate_axis, deg)
Expand Down
3 changes: 2 additions & 1 deletion docs/examples/13_curve-3-blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import os

import compas

import compas_cra
from compas_cra.datastructures import CRA_Assembly
from compas_cra.equilibrium import cra_solve
Expand All @@ -13,7 +14,7 @@
FILE_I = os.path.join(compas_cra.SAMPLE, "curve-3-blocks.json")

assembly = compas.json_load(FILE_I)
assembly = assembly.copy(cls=CRA_Assembly)
assembly: CRA_Assembly = assembly.copy(cls=CRA_Assembly)
assembly.set_boundary_conditions([0])

cra_solve(assembly, verbose=True, timer=True, density=density)
Expand Down
3 changes: 2 additions & 1 deletion docs/examples/14_cube-curve-short.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import os

import compas

import compas_cra
from compas_cra.datastructures import CRA_Assembly
from compas_cra.equilibrium import cra_solve
Expand All @@ -13,7 +14,7 @@
FILE_I = os.path.join(compas_cra.SAMPLE, "cube-curve-short.json")

assembly = compas.json_load(FILE_I)
assembly = assembly.copy(cls=CRA_Assembly)
assembly: CRA_Assembly = assembly.copy(cls=CRA_Assembly)
assembly.set_boundary_conditions([0])

cra_solve(assembly, verbose=True, timer=True, density=density)
Expand Down
3 changes: 2 additions & 1 deletion docs/examples/15_cube-curve-tall.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import os

import compas

import compas_cra
from compas_cra.datastructures import CRA_Assembly
from compas_cra.equilibrium import cra_solve
Expand All @@ -13,7 +14,7 @@
FILE_I = os.path.join(compas_cra.SAMPLE, "cube-curve-tall.json")

assembly = compas.json_load(FILE_I)
assembly = assembly.copy(cls=CRA_Assembly)
assembly: CRA_Assembly = assembly.copy(cls=CRA_Assembly)
assembly.set_boundary_conditions([0])

cra_solve(assembly, verbose=True, timer=True, density=density)
Expand Down
3 changes: 2 additions & 1 deletion docs/examples/16_ha.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import os

import compas

import compas_cra
from compas_cra.algorithms import assembly_interfaces_numpy
from compas_cra.datastructures import CRA_Assembly
Expand All @@ -15,7 +16,7 @@
deg = 0 # rotation in degree

assembly = compas.json_load(os.path.join(compas_cra.SAMPLE, "A.json" if IS_A else "H.json"))
assembly = assembly.copy(cls=CRA_Assembly)
assembly: CRA_Assembly = assembly.copy(cls=CRA_Assembly)
assembly.set_boundary_conditions([0, 1])

assembly_interfaces_numpy(assembly, nmax=10, amin=1e-2, tmax=1e-2)
Expand Down
4 changes: 1 addition & 3 deletions env_linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@ name: cra-dev
channels:
- conda-forge
dependencies:
- git
- python
- pip
- compas
- compas >=2.4
- compas_viewer
- ipopt ==3.14.9
- pyomo ==6.4.2
- matplotlib
- pip:
- compas_assembly >=0.7.0
- -r requirements-dev.txt
Expand Down
4 changes: 1 addition & 3 deletions env_osx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@ name: cra-dev
channels:
- conda-forge
dependencies:
- git
- python
- pip
- compas
- compas >=2.4
- compas_viewer
- ipopt ==3.14.9
- pyomo ==6.4.2
- matplotlib
- pip:
- compas_assembly >=0.7.0
- -r requirements-dev.txt
Expand Down
4 changes: 1 addition & 3 deletions env_win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@ name: cra-dev
channels:
- conda-forge
dependencies:
- git
- python
- pip
- compas
- compas >=2.4
- compas_viewer
- ipopt ==3.14.9
- pyomo ==6.4.2
- matplotlib
- pip:
- compas_assembly >=0.7.0
- -r requirements-dev.txt
Expand Down
3 changes: 0 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
pyomo ==6.4.2
compas >=2.0
compas_assembly >=0.7.0
2 changes: 1 addition & 1 deletion src/compas_cra/data/samples/A.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"dtype": "compas_cra.datastructures/CRA_Assembly", "value": {"graph": {"node": {"1": {"block": {"dtype": "compas_assembly.datastructures/Block", "value": {"max_vertex": 7, "max_face": 5, "dfa": {}, "vertex": {"0": {"y": 0.5, "z": 1.4614737033843994, "x": -0.19544827938079834}, "1": {"y": -0.5, "z": 1.4614737033843994, "x": -0.19544827938079834}, "2": {"y": 0.5, "z": 1.5614736080169678, "x": -0.36865335702896118}, "3": {"y": -0.5, "z": 1.5614736080169678, "x": -0.36865335702896118}, "4": {"y": 0.5, "z": -1.0499999523162842, "x": -1.6454483270645142}, "5": {"y": -0.5, "z": -1.0499999523162842, "x": -1.6454483270645142}, "6": {"y": 0.5, "z": -0.94999998807907104, "x": -1.8186533451080322}, "7": {"y": -0.5, "z": -0.94999998807907104, "x": -1.8186533451080322}}, "dea": {}, "face": {"0": [6, 4, 5, 7], "1": [4, 0, 1, 5], "2": [0, 2, 3, 1], "3": [2, 6, 7, 3], "4": [6, 2, 0, 4], "5": [1, 3, 7, 5]}, "facedata": {"0": {}, "1": {}, "2": {}, "3": {}, "4": {}, "5": {}}, "attributes": {"name": null, "node": null}, "dva": {"y": 0.0, "z": 0.0, "x": 0.0}, "edgedata": {}}, "guid": "cd02ecff-e9c5-41fc-aa33-12e1371686a2"}}, "2": {"block": {"dtype": "compas_assembly.datastructures/Block", "value": {"max_vertex": 7, "max_face": 5, "dfa": {}, "vertex": {"0": {"y": 0.5, "z": -0.20000000298023224, "x": 1.1547005176544189}, "1": {"y": -0.5, "z": -0.20000000298023224, "x": 1.1547005176544189}, "2": {"y": 0.5, "z": 0.60000002384185791, "x": 0.69282031059265137}, "3": {"y": -0.5, "z": 0.60000002384185791, "x": 0.69282031059265137}, "4": {"y": 0.5, "z": 0.60000002384185791, "x": -0.69282031059265137}, "5": {"y": -0.5, "z": 0.60000002384185791, "x": -0.69282031059265137}, "6": {"y": 0.5, "z": -0.20000000298023224, "x": -1.1547005176544189}, "7": {"y": -0.5, "z": -0.20000000298023224, "x": -1.1547005176544189}}, "dea": {}, "face": {"0": [2, 4, 5, 3], "1": [4, 6, 7, 5], "2": [6, 0, 1, 7], "3": [0, 2, 3, 1], "4": [2, 0, 6, 4], "5": [7, 1, 3, 5]}, "facedata": {"0": {}, "1": {}, "2": {}, "3": {}, "4": {}, "5": {}}, "attributes": {"name": null, "node": null}, "dva": {"y": 0.0, "z": 0.0, "x": 0.0}, "edgedata": {}}, "guid": "e2500a76-48c7-477d-a365-d1d621531ffc"}}, "0": {"block": {"dtype": "compas_assembly.datastructures/Block", "value": {"max_vertex": 7, "max_face": 5, "dfa": {}, "vertex": {"0": {"y": 0.5, "z": -0.94999998807907104, "x": 1.8186533451080322}, "1": {"y": -0.5, "z": -0.94999998807907104, "x": 1.8186533451080322}, "2": {"y": 0.5, "z": -1.0499999523162842, "x": 1.6454483270645142}, "3": {"y": -0.5, "z": -1.0499999523162842, "x": 1.6454483270645142}, "4": {"y": 0.5, "z": 1.5614736080169678, "x": 0.36865335702896118}, "5": {"y": -0.5, "z": 1.5614736080169678, "x": 0.36865335702896118}, "6": {"y": 0.5, "z": 1.4614737033843994, "x": 0.19544827938079834}, "7": {"y": -0.5, "z": 1.4614737033843994, "x": 0.19544827938079834}}, "dea": {}, "face": {"0": [2, 0, 1, 3], "1": [0, 4, 5, 1], "2": [4, 6, 7, 5], "3": [6, 2, 3, 7], "4": [2, 6, 4, 0], "5": [5, 7, 3, 1]}, "facedata": {"0": {}, "1": {}, "2": {}, "3": {}, "4": {}, "5": {}}, "attributes": {"name": null, "node": null}, "dva": {"y": 0.0, "z": 0.0, "x": 0.0}, "edgedata": {}}, "guid": "6e944093-e539-4202-9944-d783070f9712"}}}, "adjacency": {"1": {}, "2": {}, "0": {}}, "max_node": 2, "dna": {"section": null, "is_support": false, "displacement": [0, 0, 0, 0, 0, 0], "mesh_size": null, "block": null}, "edge": {"1": {}, "2": {}, "0": {}}, "attributes": {"name": "Graph"}, "dea": {"interfaces": [], "interface": null}}, "attributes": {"name": "CRA_Assembly"}}, "guid": "1bc4d347-fadf-419f-baa3-0bf1856bbc7e"}
{"dtype": "compas_cra.datastructures/CRA_Assembly", "data": {"graph": {"dtype": "compas.datastructures/Graph", "data": {"node": {"1": {"block": {"dtype": "compas_assembly.datastructures/Block", "data": {"max_vertex": 7, "max_face": 5, "default_face_attributes": {}, "vertex": {"0": {"y": 0.5, "z": 1.4614737033843994, "x": -0.19544827938079834}, "1": {"y": -0.5, "z": 1.4614737033843994, "x": -0.19544827938079834}, "2": {"y": 0.5, "z": 1.5614736080169678, "x": -0.3686533570289612}, "3": {"y": -0.5, "z": 1.5614736080169678, "x": -0.3686533570289612}, "4": {"y": 0.5, "z": -1.0499999523162842, "x": -1.6454483270645142}, "5": {"y": -0.5, "z": -1.0499999523162842, "x": -1.6454483270645142}, "6": {"y": 0.5, "z": -0.949999988079071, "x": -1.8186533451080322}, "7": {"y": -0.5, "z": -0.949999988079071, "x": -1.8186533451080322}}, "default_edge_attributes": {}, "face": {"0": [6, 4, 5, 7], "1": [4, 0, 1, 5], "2": [0, 2, 3, 1], "3": [2, 6, 7, 3], "4": [6, 2, 0, 4], "5": [1, 3, 7, 5]}, "facedata": {"0": {}, "1": {}, "2": {}, "3": {}, "4": {}, "5": {}}, "attributes": {"name": null, "node": null}, "default_vertex_attributes": {"y": 0.0, "z": 0.0, "x": 0.0}, "edgedata": {}}, "guid": "cd02ecff-e9c5-41fc-aa33-12e1371686a2"}}, "2": {"block": {"dtype": "compas_assembly.datastructures/Block", "data": {"max_vertex": 7, "max_face": 5, "default_face_attributes": {}, "vertex": {"0": {"y": 0.5, "z": -0.20000000298023224, "x": 1.154700517654419}, "1": {"y": -0.5, "z": -0.20000000298023224, "x": 1.154700517654419}, "2": {"y": 0.5, "z": 0.6000000238418579, "x": 0.6928203105926514}, "3": {"y": -0.5, "z": 0.6000000238418579, "x": 0.6928203105926514}, "4": {"y": 0.5, "z": 0.6000000238418579, "x": -0.6928203105926514}, "5": {"y": -0.5, "z": 0.6000000238418579, "x": -0.6928203105926514}, "6": {"y": 0.5, "z": -0.20000000298023224, "x": -1.154700517654419}, "7": {"y": -0.5, "z": -0.20000000298023224, "x": -1.154700517654419}}, "default_edge_attributes": {}, "face": {"0": [2, 4, 5, 3], "1": [4, 6, 7, 5], "2": [6, 0, 1, 7], "3": [0, 2, 3, 1], "4": [2, 0, 6, 4], "5": [7, 1, 3, 5]}, "facedata": {"0": {}, "1": {}, "2": {}, "3": {}, "4": {}, "5": {}}, "attributes": {"name": null, "node": null}, "default_vertex_attributes": {"y": 0.0, "z": 0.0, "x": 0.0}, "edgedata": {}}, "guid": "e2500a76-48c7-477d-a365-d1d621531ffc"}}, "0": {"block": {"dtype": "compas_assembly.datastructures/Block", "data": {"max_vertex": 7, "max_face": 5, "default_face_attributes": {}, "vertex": {"0": {"y": 0.5, "z": -0.949999988079071, "x": 1.8186533451080322}, "1": {"y": -0.5, "z": -0.949999988079071, "x": 1.8186533451080322}, "2": {"y": 0.5, "z": -1.0499999523162842, "x": 1.6454483270645142}, "3": {"y": -0.5, "z": -1.0499999523162842, "x": 1.6454483270645142}, "4": {"y": 0.5, "z": 1.5614736080169678, "x": 0.3686533570289612}, "5": {"y": -0.5, "z": 1.5614736080169678, "x": 0.3686533570289612}, "6": {"y": 0.5, "z": 1.4614737033843994, "x": 0.19544827938079834}, "7": {"y": -0.5, "z": 1.4614737033843994, "x": 0.19544827938079834}}, "default_edge_attributes": {}, "face": {"0": [2, 0, 1, 3], "1": [0, 4, 5, 1], "2": [4, 6, 7, 5], "3": [6, 2, 3, 7], "4": [2, 6, 4, 0], "5": [5, 7, 3, 1]}, "facedata": {"0": {}, "1": {}, "2": {}, "3": {}, "4": {}, "5": {}}, "attributes": {"name": null, "node": null}, "default_vertex_attributes": {"y": 0.0, "z": 0.0, "x": 0.0}, "edgedata": {}}, "guid": "6e944093-e539-4202-9944-d783070f9712"}}}, "adjacency": {"1": {}, "2": {}, "0": {}}, "max_node": 2, "default_node_attributes": {"section": null, "is_support": false, "displacement": [0, 0, 0, 0, 0, 0], "mesh_size": null, "block": null}, "edge": {"1": {}, "2": {}, "0": {}}, "attributes": {"name": "Graph"}, "default_edge_attributes": {"interfaces": [], "interface": null}}}, "attributes": {"name": "CRA_Assembly"}}, "guid": "1bc4d347-fadf-419f-baa3-0bf1856bbc7e"}
Loading

0 comments on commit 3fbb019

Please sign in to comment.