Skip to content

Commit

Permalink
Remove cpp optimizations (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
jvail committed Sep 3, 2023
1 parent 1ecea95 commit 3e4ed26
Show file tree
Hide file tree
Showing 16 changed files with 185 additions and 544 deletions.
3 changes: 0 additions & 3 deletions binder/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ dependencies:
- toml
- matplotlib
- scipy
- boost
- boost-cpp
- cppyy=2.4
- openalea.lpy
- openalea.plantgl=3.20.1
- openalea.mtg
Expand Down
22 changes: 19 additions & 3 deletions notebooks/simple_simulation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"id": "c53a8105-14b5-437b-91ce-604152bb9c61",
"metadata": {
"tags": []
Expand All @@ -17,12 +17,28 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 2,
"id": "b74cb80a-cac4-4d6f-ae18-165a52517072",
"metadata": {
"tags": []
},
"outputs": [],
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "47503da9c36d4478af4b36964c741add",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"SceneWidget(scenes=[{'id': 'XaKImpeVjzSwKnKEkcfVxz8VN', 'data': b'x\\xdaSLrw\\xf5\\xf7e`Pp\\xe0\\xe5RPVVd\\x00\\x020\\"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"widget = SceneWidget()\n",
"widget"
Expand Down
7 changes: 1 addition & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
[build-system]
requires = [
"setuptools>=58",
"scikit-build>=0.17",
"cmake>=3.18",
"ninja",
]
requires = ["setuptools>=58"]
build-backend = "setuptools.build_meta"

[project]
Expand Down
1 change: 0 additions & 1 deletion test/notebooks/README.md

This file was deleted.

204 changes: 0 additions & 204 deletions test/notebooks/optimization.ipynb

This file was deleted.

3 changes: 1 addition & 2 deletions test/test_metamer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@

from vmapplet import Simulation, Options
from vmapplet.organs.metamer import MetamerData, CambialLayer
from vmapplet.optimisation import reaction_wood_target
from vmapplet.organs.wood import Wood
from vmapplet.organs.fruit import AppleFruit
from vmapplet.organs.leaf import AppleLeaf
from vmapplet.organs.internode import Internode
from vmapplet.physics import Frame
from vmapplet.physics import Frame, reaction_wood_target
from vmapplet.enums import FruitState


Expand Down
11 changes: 0 additions & 11 deletions test/test_physics.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
second_moment_of_area_circular_section,
Frame,
rotate_frame_at_branch,
reorient_frame,
)


Expand Down Expand Up @@ -52,13 +51,3 @@ def test_rotate_frame_at_branch():
v3 = Vector3(1, 1, 2)
frame = Frame(v1, v2, v3)
rotate_frame_at_branch(frame, 45, 45)


def test_reorient_frame():
v1 = Vector3(2, 1, 1)
v2 = Vector3(1, 2, 1)
v3 = Vector3(1, 1, 2)
rotation_velocity = Vector3(1, 1, 1)
length = 1
frame = Frame(v1, v2, v3)
reorient_frame(frame, rotation_velocity, length)
9 changes: 5 additions & 4 deletions vmapplet/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
from typing import Optional
from typing import Optional, TYPE_CHECKING

from pgljupyter import SceneWidget
if TYPE_CHECKING:
from pgljupyter import SceneWidget

from ._cppyy import * # noqa
# from ._cppyy import * # noqa
from .simulation import Simulation
from .options import Options


def run(simulation: Simulation, scene_widget: Optional[SceneWidget] = None):
def run(simulation: Simulation, scene_widget: Optional["SceneWidget"] = None):
""" """

date_start = simulation.options.general.date_start
Expand Down
10 changes: 0 additions & 10 deletions vmapplet/_cppyy.py

This file was deleted.

18 changes: 9 additions & 9 deletions vmapplet/lpy/mechanics_backward.lpy
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import openalea.plantgl.all as pgl

from vmapplet import (
constants,
optimisation
constants
)
from vmapplet.enums import LeafState
from vmapplet.physics import *

gravity = pgl.Vector3(0.0, 0.0, -9.81)

Expand All @@ -28,10 +28,10 @@ root() >> metamer(m):
tree.fruit_load = tree.fruits / tree.trunk_cross_sectional_area

metamer(m) >> SB() branch() metamer(mb) EB() metamer(mr):
radius = optimisation.get_new_radius(mb.radius, mr.radius)
radius = get_new_radius(mb.radius, mr.radius)
if m.leaf.state == LeafState.GROWING:
radius = optimisation.get_new_radius(radius, m.leaf.petiole_radius)
m.radius = optimisation.max(radius, m.radius);
radius = get_new_radius(radius, m.leaf.petiole_radius)
m.radius = max(radius, m.radius);
# update last layer thickness
m.layers[-1].thickness = m.radius - m.layers[-1].radius
m.compute_mass(mr, mb)
Expand All @@ -49,8 +49,8 @@ metamer(m) >> SB() branch() metamer(mb) EB() metamer(mr):
metamer(m) >> metamer(mr):
radius = mr.radius
if m.leaf.state == LeafState.GROWING:
radius = optimisation.get_new_radius(mr.radius, m.leaf.petiole_radius)
m.radius = optimisation.max(radius, m.radius)
radius = get_new_radius(mr.radius, m.leaf.petiole_radius)
m.radius = max(radius, m.radius)
m.layers[-1].thickness = m.radius - m.layers[-1].radius
m.compute_mass(mr)
if options.general.mechanics:
Expand All @@ -66,8 +66,8 @@ metamer(m) >> apex(a):
# wood.density, m.fruit_mass are units objects
radius = a.radius
if m.leaf.state == LeafState.GROWING:
radius = optimisation.get_new_radius(a.radius, m.leaf.petiole_radius)
m.radius = optimisation.max(radius, m.radius)
radius = get_new_radius(a.radius, m.leaf.petiole_radius)
m.radius = max(radius, m.radius)
m.layers[-1].thickness = m.radius - m.layers[-1].radius
m.compute_mass()
m.cumulated_torque = cross( m.hlu.heading * m.length, tree.tropism)
Expand Down
Loading

0 comments on commit 3e4ed26

Please sign in to comment.