Skip to content

Commit

Permalink
Merge pull request #67 from TUDelft-CITG/debug/small-fixes
Browse files Browse the repository at this point in the history
Debug/small fixes
  • Loading branch information
uijl committed Jul 26, 2019
2 parents 6be31d4 + 9739d27 commit d9b1536
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 17 deletions.
7 changes: 6 additions & 1 deletion HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
History
=======

1.0.1 (2019-07-26)
------------------

* Small bug fixes

1.0.0 (2019-07-10)
------------------

Expand All @@ -10,7 +15,7 @@ History
0.3.0 (2019-06-20)
------------------

* First release to PyPI and rename to OpenClSim
* First release to PyPI and rename to OpenCLSim

v0.2.0 (2019-02-14)
------------------
Expand Down
2 changes: 1 addition & 1 deletion docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ To install OpenCLSim, run this command in your terminal:

.. code-block:: bash
# Use pip to install OpenClSim
# Use pip to install OpenCLSim
pip install openclsim
This is the preferred method to install OpenCLSim, as it will always install the most recent stable release.
Expand Down
2 changes: 1 addition & 1 deletion docs/openclsim-api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
OpenCLSim API
=============

A flask server is part of the OpenCLSim package. This allows using the python code from OpenClSim from a separate front-end.
A flask server is part of the OpenCLSim package. This allows using the python code from OpenCLSim from a separate front-end.

Starting the Flask Server
-------------------------
Expand Down
2 changes: 1 addition & 1 deletion openclsim/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

__author__ = """Mark van Koningsveld"""
__email__ = "M.vanKoningsveld@tudelft.nl"
__version__ = "1.0.0"
__version__ = "1.0.1"
40 changes: 33 additions & 7 deletions openclsim/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1112,7 +1112,6 @@ def check_optimal_filling(self, loader, unloader, origin, destination):
origin,
destination,
filling * self.container.capacity - self.container.level,
False,
)

orig = shapely.geometry.asShape(origin.geometry)
Expand Down Expand Up @@ -1230,6 +1229,7 @@ def move(self, destination, engine_order=1.0):
# Determine distance based on geometry objects
# Determine speed based on filling degree
distance, speed = self.get_distance(self.geometry, destination)

else:
# Determine distance based on geometry objects
distance = self.get_distance(self.geometry, destination)
Expand Down Expand Up @@ -1495,11 +1495,11 @@ def unloading(self, origin, destination, amount):
"""

if not hasattr(self.unloading_rate, "__call__"):
return amount / self.unloading_rate + self.load_manoeuvring * 60
return amount / self.unloading_rate + self.unload_manoeuvring * 60
else:
return (
self.unloading_rate(self.container.level, self.container.level - amount)
+ self.load_manoeuvring * 60
+ self.unload_manoeuvring * 60
)


Expand Down Expand Up @@ -1648,12 +1648,25 @@ def process(self, ship, desired_level, site):

# Checkout the time
origin.log_entry(
"unloading start", self.env.now, amount, self.geometry, self.ActivityID
"unloading start",
self.env.now,
origin.container.level,
self.geometry,
self.ActivityID,
)
destination.log_entry(
"loading start", self.env.now, amount, self.geometry, self.ActivityID
"loading start",
self.env.now,
destination.container.level,
self.geometry,
self.ActivityID,
)

if self != origin and self != destination:
self.log_entry(
"loading start", self.env.now, 0, self.geometry, self.ActivityID
)

# Check out the time
yield self.env.timeout(duration)

Expand All @@ -1667,12 +1680,25 @@ def process(self, ship, desired_level, site):
self.computeEnergy(duration, origin, destination)

origin.log_entry(
"unloading stop", self.env.now, amount, self.geometry, self.ActivityID
"unloading stop",
self.env.now,
origin.container.level + amount,
self.geometry,
self.ActivityID,
)
destination.log_entry(
"loading stop", self.env.now, amount, self.geometry, self.ActivityID
"loading stop",
self.env.now,
destination.container.level + amount,
self.geometry,
self.ActivityID,
)

if self != origin and self != destination:
self.log_entry(
"loading stop", self.env.now, amount, self.geometry, self.ActivityID
)

start_time = self.env.now
yield destination.container.put(amount)
end_time = self.env.now
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,6 @@
test_suite="tests",
tests_require=tests_require,
url="https://github.com/TUDelft-CITG/openclsim",
version="1.0.0",
version="1.0.1",
zip_safe=False,
)
10 changes: 5 additions & 5 deletions tests/test_energy_use.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,14 @@ def test_processor(
env.process(processor.process(source, 400, dest))
env.run()

np.testing.assert_almost_equal(processor.log["Value"][-1], (env.now - start) * 4)
np.testing.assert_almost_equal(processor.log["Value"][-2], (env.now - start) * 4)

# Log fuel use of the processor in step 2
start = env.now
env.process(processor.process(dest, 300, source))
env.run()

np.testing.assert_almost_equal(processor.log["Value"][-1], (env.now - start) * 4)
np.testing.assert_almost_equal(processor.log["Value"][-2], (env.now - start) * 4)


# Test energy use of a TransportProcessingResource
Expand Down Expand Up @@ -234,7 +234,7 @@ def test_TransportProcessingResource(
env.run()

# Duration should be amount / 2
# Energy use duration * 4
# Energy use should be duration * 4
np.testing.assert_almost_equal(hopper.log["Value"][-2], (env.now - start) * 4)

# Simulation continues with moving from A to B
Expand Down Expand Up @@ -343,7 +343,7 @@ def test_Processor_ContainerDependentMovable(
env.process(processor_1.process(containervessel, 500, source))
env.run()

np.testing.assert_almost_equal(processor_1.log["Value"][-1], (env.now - start) * 4)
np.testing.assert_almost_equal(processor_1.log["Value"][-2], (env.now - start) * 4)

# Simulation continues with moving from A to B
start = env.now
Expand All @@ -359,4 +359,4 @@ def test_Processor_ContainerDependentMovable(
env.process(processor_2.process(containervessel, 0, dest))
env.run()

np.testing.assert_almost_equal(processor_2.log["Value"][-1], (env.now - start) * 3)
np.testing.assert_almost_equal(processor_2.log["Value"][-2], (env.now - start) * 3)

0 comments on commit d9b1536

Please sign in to comment.