Introduction

With the development of artificial intelligence technology and new energy technology, the ship energy system has become a complex and compact distributed system. As the frequency of international trade exchanges increase, the total demand for transportation is increasing year by year, resulting in increased the carbon emissions and serious marine pollution. Under the goal of carbon peak and carbon neutralization, it is urgent to develop low-carbon or even zero-carbon transportation. [1] Among the existing transportation modes, waterway transportation, which produces huge carbon emissions, has always occupied a large proportion. Therefore, reducing the carbon emissions from shipping industry has become the focus of many researchers. The ship energy management is the key to reduce energy consumption and improve energy efficiency, which has been widely concerned in the development of shipping industry.

The essence of the energy management problem for the ship energy system is an optimization problem of a complex system. The ship energy management plan is an indispensable part of the energy management system implemented by shipping enterprises, which can strictly control and manage ship energy consumption, energy utilization efficiency and carbon dioxide emissions. For the ship energy management problem, Wen [2] developed a data-driven optimization scheme considering navigation routing dependent on photovoltaic (PV). In order to minimize the total cost and greenhouse gas emissions of all-electric ship (AES), a new coordinated optimization framework is proposed to jointly optimize the size and voyage scheduling of energy storage system (ESS) while considering the change of solar energy. Yuan [3] proposed that the fuzzy logic energy management strategy can optimize the operating conditions of individual power generation sources, improve the overall performance of the power system and reduce the fossil fuel consumption of ships. Yigit [4] considered a new algorithm for ship power management based on a smart grid feature of a mix of renewable energy, energy storage, shore-based power connections and different types of bunker fuels to minimize the environmental impact of ship navigation. Kalikatzarakis [5] applied the Equivalent Consumption Minimisation Strategy (ECMS) to a ship powered by a hybrid propulsion plant with hybrid power supply that can be recharged with renewable shore power. To this end, a Mixed-Integer Non-Linear optimisation Problem was formulated and solved by combining Branch & Bound and Convex optimisation. To reduce ship energy consumption, Lan [6] proposed a method for determining the optimal size of the photovoltaic (PV) generation system, the diesel generator and the energy storage system in a stand-alone ship power system and temperatured along the route from Dalian in China to Aden in Yemen into account, that minimizes the investment cost, fuel cost and the CO2 emissions. Banaei [7] proposed an integrated power system (IPS) based on fuel cell (FC), battery, photovoltaic panels (PV), and two diesel generators and modeled for an all-electric ship to address a solution for the high pollution resulting from conventional ships. A decentralized model predictive control (MPC) strategy is also designed to control the modules of the IPS. Although the use of fossil fuel during ship operation is reducing and the use rate of clean energy is increasing, the treatment cost of the carbon emission generated while using fossil fuel is huge, and its economy and environmental protection issue have been widely concerned by scholars [8, 9]. In the process of decarbonization transformation of shipping industry, carbon capture and storage technology can be used to collect and store carbon dioxide generated by ship power generation equipment, which can avoid environmental pollution. In the multi-objective optimization framework, Alireza [10] solved the economic-emission dispatch problem of renewable energy and coal-fired power plants equipped with carbon capture systems. Zhang [11] presented a coupling model considering power to gas (P2G) technology and carbon capture power plants (CCPP), and extends it into an integrated energy system (IES) including electricity, thermal and gas, then proposes an economic and environment-friendly scheduling model at a high wind power penetration level. To reduce carbon dioxide emissions from ships, Li [12] proposed a stochastic unit commitment (UC) model to realize the low-carbon operation requirement and coped with wind power prediction errors for power systems with intensive wind power and carbon capture power plant (CCPP). However, because the ship is a closed and narrow space with limited capacity, it cannot carry large-scale carbon capture equipment, and the carbon capture technology cannot adapt to the mode of ship sailing at sea. Therefore, the government considers to realize low carbon or even zero carbon by levying carbon tax [13]. At present, how to use carbon tax to describe the cost of the ship carbon emission treatment has attracted widespread attention. Wang [14] considered the speed optimization problem of the ship carbon emission, and analyzed the impact of three different forms of carbon tax models on the ship carbon emission. Dan [15] constructed a mixed integer nonlinear programming model with the objective of minimizing the operating cost by considering the ship carbon tax, and proposed an applicable dynamic programming method and developed a suitable solution to solve the problem. Liu [16] proposed a bi-objective optimization model for carbon tax imposed on liner shipping system and network trading mechanism, and used genetic algorithm to solve the problem. Therefore, this paper intends to use carbon tax to depict the cost of ship carbon emission treatment, and comprehensively considers the energy management methods of the ship entering and leaving to reduce the ship operation cost.

The centralized method is usually used to solve the problem of the ship energy management. However, due to the high single point failure rate of centralized method and the rapid increase of ship data calculation with the development of the intelligent ship, centralized method cannot accurately and efficiently process a large amount of data. Meanwhile, for the low-carbon ship micro-grid containing large-scale clean energy, due to its power system connected to various new energy power supply forms [17], its power generation equipment and distributed structure presented by load, which is more appropriate to use distributed method based on multi-agent system to solve its energy management problem [18, 19]. Edrington [20] proposed a distributed energy management scheme for ship power systems to address the use of supplementary energy when high loads are suddenly introduced in isolated microgrids, which reduces the impact on generators. Lai [21] proposed an improved ADMM-based distributed energy management strategy to further meet the needs of resilience, economy, and privacy protection required by shipboard power systems. Zhang [22] proposed a distributed optimal scheduling algorithm based on load prediction to solve the problem considering the ship navigation economy as the goal and then ensure the safety of ship navigation. Although the distributed algorithm of the ship energy management has been studied, the energy management problem of ships entering and leaving ports also needs to consider the connection between ship power system and port power grid, which is different from the energy management problem of single ship sailing.

With the rapid development of information technologies such as the Internet, cloud computing and the Internet of Things, some large shipping companies have gradually established a global ship operation data center to monitor and manage the position, navigation status and equipment status of ships. With the increasing complexity and accuracy of the intelligent ship control and optimization method, the data generated by the Internet and the Internet of Things increases by geometric multiples. Under the double-layer superposition of the data scale and the method, the demand for computing power is increasing. The current Internet economy is mostly centralized and group-oriented development, which does not bring good application scenarios to distributed computing power and develop appropriate operation mode, so as to make distributed computing power cannot achieve targeted application. As the core productivity of digital economy, computing power has become the new focus of global strategic competition. At present, there have been many studies on the power consumption of computing systems. Hogade [23] managed geographically distributed data centers to minimize energy consumption by considering detailed data center cooling power, co-location interference, electricity pricing, renewable energy, net metering, and peak demand pricing distribution models. Beloglazov [24] proposed an architecture of cloud energy saving management, which realizes significant reduction of data center power consumption cost while considering the energy-saving resource allocation strategy and scheduling algorithm of the quality of service (QOS) expectation and the power utilization characteristics of equipment, which shows great potential for improving energy efficiency under dynamic workload scenarios. Wang [25] proposed a branch-and-bound algorithm to obtain a global optimal solution and a heuristic algorithm with low computational complexity to obtain an alternative solution close to the optimal solution, which distributes the computational workload among multiple geographically dispersed data centers by using the difference in electricity price to reduce the energy cost of the data center. Therefore, in the distributed energy management of ships, how to reduce the power consumption of shipboard data center to reduce the carbon emission of ships and achieve green ships is a problem that needs to be solved.

Considering the ship operation cost, the ship distributed energy management system tends to reduce the carbon emission and ensure that the ship has sufficient computing resources. At present, the integration of ship microgrid and power calculation network is being considered to establish a comprehensive power calculation network and ship microgrid. In the process of the ship energy management, a variety of data information interaction among different equipment is required, but the existing traditional IP communication network architecture cannot meet the demand for real time, reliability and safety level of ship information communication. A network architecture in [26] with intelligence, high efficiency and high robustness for ship communication is needed. A sovereign network and a high-security private network in [27] under an autonomous polymorphic identification space are established to support data interaction of the ship distributed energy management systems under different data streams. Therefore, this paper proposes an energy management system for ships entering and leaving ports based on polymorphic network by combining multi-target and polymorphic information observed by different equipment.

To sum up, the innovation points of this paper are as follows

  1. 1.

    A polymorphic network-based energy management system is constructed for ships entering and leaving ports, which improves the information exchange of power flow, computing power flow and carbon flow among distributed equipment on board. At the same time, the ship’s computing resource allocation is considered to improve the ship’s energy efficiency.

  2. 2.

    A distributed energy management method for ships entering and leaving ports is proposed to reduce the operating cost and carbon emissions of ships entering and leaving ports. The carbon tax is used to deal with the carbon emissions from ships and ships are encouraged to give priority to using new energy for power supply. The ship is powered by the ship’s power generation equipment and is in island mode before berthing. And the distributed average consensus algorithm is used to obtain the optimal energy management solution. Meanwhile, the ship microgrid is connected to the port power system and mainly powered by shore power when berthing. And the distributed leader–follower consensus is used to solve the problem.

Polymorphic energy management system

System structure

Distributed energy management for ships entering and exiting ports relies on the interaction of information from a variety of data such as power flow, computing flow and carbon flow between the ship’s distributed equipment, which reduces the ship’s operating costs and reduces the ship’s carbon footprint. Therefore, the requirements for real time, reliability and security level of information communication are higher, which cannot be met by the existing traditional IP communication network architecture. To meet the development demand of intelligent, high performance and high robustness of ship communication network, in this paper, a polymorphic network-based energy management system for entering and leaving ports is proposed, as shown in Fig. 1.

Fig. 1
figure 1

Polymorphic architecture diagram of the proposed energy management system

The polymorphic network-based energy management system for ships entering and leaving ports is mainly divided into three layers: data layer, control layer and service layer. Its data layer is externally connected to physical equipment such as shipboard data center, ship power supply equipment and port shore power, as shown in Fig. 1. Among them, the data layer is responsible for storing relevant data used for the energy management of ships entering and leaving ports, which can define the communication protocols, interfaces and topologies of the ships entering and leaving ports energy management system in full dimensions. The data layer provides services for diversified applications of the energy management of ships entering and leaving ports, and provides basic support for realizing the intelligence and flexibility of ship communication. The control layer is responsible for taking over the service layer and controlling the data layer. And it is also responsible for domain management, rights management and other tasks that are more integrated with the physical layer power supply. Simultaneously, logging of the routing status within the domain and authentication of requests within the domain after completion of the verification of the ship information and after consensus have been reached in the control layer. Diverse routing can be defined according to service requirements by the ship’s polymorphic controller, and domain name management and authority management between polymorphic network can be realized, laying the foundation for the distributed energy management in ships. The service layer is responsible for implementing the distributed energy management for ships entering and leaving port. Firstly, an energy management model is established for ships entering and leaving ports. Secondly, the computing resources of the ships is analyzed, and finally the distributed energy management method according to the navigation status of the ship is designed.

The polymorphic network-based energy management system for ships entering and leaving ports proposed in this paper is a new domain name management system with polymorphic addressing, efficient availability and privacy protection, which can enhance the security of ship communication network. The proposed energy management systems are no longer limited to the existing IP network architecture and protocols, and can fully meet the evolving requirements of ship communication services.

Fig. 2
figure 2

The overall operational architecture of a ship’s data center

Computing resource analysis

As the development of smart ships and their distributed technologies becomes more advanced, the generated data grows significantly and the demand for computing power grows. Therefore, the power consumption of shipboard data centers grows rapidly leading the cost of consuming computing resources gradually dominates the cost of ship operation. As the computing carrier for ship operation, shipboard data centers play an important role in promoting the green and low-carbon development of ships. Thus, this paper considers the energy consumption of computing resources in the distributed energy management of ships entering and leaving ports, and a shipboard data center power consumption model is proposed to reduce the cost of ship computing resources consumption and the ship operation cost.

Fig. 3
figure 3

Schematic diagram of the shipboard data center structure

Shipboard data centers

The brief architecture of a shipboard data center is shown in Fig. 2. Firstly, the operation of the shipboard data center starts with the arrival of data loads, with the input being the total data load arriving and the output being the power demand of each shipboard data center, which can be divided into three main components: the power consumption of the IT equipment, the power consumption of the cooling system and the power consumption of other equipment. Specifically, the IT equipment handles the incoming data load to ensure the smooth operation of the ship. The cooling system provides cooling power to remove the heat generated by IT and other equipment and then the internal ambient temperature of the ship’s data center can be maintained. There is still some other equipment such as lighting systems, security systems, fire suppression system and waterproofing systems, which ensures stable operation of the shipboard data center, reduces energy costs and keeps the system running sustainably.

In terms of IT equipment, there are four main types of electronic equipment in a shipboard data center: processors for data computing, switches, routers and other equipment for data communication, storage equipment for data storage and monitoring and other equipment for IT management support. For other equipment, such as the cooling system, the cooling infrastructure, i.e. fans and air conditioners, can be used to cool and then ensure the smooth operation of the shipboard data center. The overall structure is shown in Fig. 3. Based on this, we can construct a shipboard data center power consumption model to facilitate ship operation cost calculation.

Assumption of power consumption model for shipboard data center

Define the set of time slots as \(T=\left\{ 1,2,\cdots ,U \right\} \), where the data load allocation decision time matches the power system dispatch schedule time, e.g., 1 h [28]. Define a set of shipboard data centers distributed at different power nodes as \(Q=\left\{ 1,2,\cdots ,V \right\} \). Within the time slots \(t\left( t\in T \right) \), for shipboard data centers \(j\left( j\in Q \right) \), assume that there are

  1. (1)

    Shipboard data center j is homogeneous data center, where all servers are homogeneous (performance, power rating, etc.).

  2. (2)

    Other power consumption sources in the shipboard data center j, such as network transmission equipment, cooling equipment, storage systems, lighting systems, power distribution systems, etc. can be regarded as a linear function of server power consumption.

  3. (3)

    A dynamic cluster server configuration (DCSC) is used and a minimum number of active servers are used while the shipboard data center j handling the data load at rated power, with other servers shutting down or sleeping.

  4. (4)

    The data load on the vessel is delay-sensitive, with a delay threshold D of no more than one time slot in length. The data load allocated to the shipboard data center j is evenly distributed across active servers and M/M/1 queuing model is used to estimate the average time the data load stays in the shipboard data center j, with the average stay not exceeding a latency threshold D.

Shipboard data center power consumption model

The objective of the model is to reduce shipboard data center power consumption during the ship navigation by considering the number of active servers as a decision variable, which models the functional relationship between shipboard data center power consumption and server power consumption based on the assumptions. And shipboard data center power consumption can be modelled as a linear function of the number of active servers, as follows

$$\begin{aligned} \min P_{ID{{C}_{j}},z}^{t}={{\theta }_{j}}{{m}_{j,t}}+{{\gamma }_{j}},\forall j\in Q,t\in T \end{aligned}$$
(1)

where T is the set of time slots, Q is a collection of shipboard data centers distributed across different power nodes, \(P_{IDC,z}^{t}\) is the power consumption of the shipboard data center j in the time slot t, \({{m}_{j,t}}\) is the number of active servers of shipboard data center j in the time slot t, \({{\theta }_{j}}\) is a positive constant, being the increase in power consumption of the shipboard data center j due to an increase in the number of active servers, \({{\gamma }_{j}}\) is a positive constant and is the fixed power consumption when the shipboard data center j is in operation.

The following constraints need to be considered.

Number of Servers Constraint. The number of servers in a shipboard data center is finite and can be expressed as

$$\begin{aligned} 0\le {{m}_{j,t}}\le {{M}_{j}},\forall j\in Q,t\in T \end{aligned}$$
(2)

where \({{M}_{j}}\) is the number of servers in the shipboard data center j.

Data Load Processing Delay Constraint. In order to ensure the normal navigation of the ship, the shipboard data center must process the data load within the allowed delay time. According to the assumptions, server power consumption is a linear function of the number of active servers, so the functional relationship between server power consumption and data load can be expressed as a function of the number of active servers and data load. M/M/1 queuing model is used to estimate the average stay time of the data load in the shipboard data center, and with the average stay not exceeding a delay threshold D, as the following function.

$$\begin{aligned} 0<\frac{1}{{{\mu }_{j}}-\frac{\sum \nolimits _{\delta \in \varPhi }{{{\lambda }_{\delta j,t}}}}{{{m}_{j,t}}}}\le D,\forall j\in Q,t\in T \end{aligned}$$
(3)

where \(\varPhi \) is the collection of front-end portals for ships, \({{\lambda }_{\delta j,t}}\) is the amount of data load allocated from the ship’s front-end portal server \(\delta \left( \delta \in \varPhi \right) \) to the shipboard data center j at the time slot t. \(\sum \nolimits _{\delta \in \varPhi }{{{\lambda }_{\delta j,t}}}\) is the total data load arriving at the shipboard data center j at the time slot t, \(\left( \sum \nolimits _{\delta \in \varPhi }{{{\lambda }_{\delta j,t}}} \right) /{{m}_{j,t}}\) is the amount of data load allocated to each active server arriving in the shipboard data center j at the time slot t. \({{\mu }_{j}}\) is the average service rate per active server in the shipboard data center j, or the service rate of a single active server when the servers are homogeneous, and \({{\mu }_{j}}\) is a fixed performance parameter provided by the shipboard data center that depends on server performance and the type of data load. \(1/\left[ {{\mu }_{j}}-\left( \sum \nolimits _{\delta \in \varPhi }{{{\lambda }_{\delta j,t}}} \right) /{{m}_{j,t}} \right] \) is the average time the data load stays in the shipboard data centerj under the M/M/1 queuing model [29], D is the latency limit for data load processing.

When the ship’s front-end portal is not assigned a data load, \(\sum \nolimits _{\delta \in \varPhi }{\lambda _{\delta j}^{t}}=0\), and the minimum number of active servers considered to satisfy the latency constraint D is \({{m}_{j,t}}=0\). This gives the number of active servers \({{m}_{j,t}}\) as a function of data load \(\lambda _{\delta j}^{t}\), as follows

$$\begin{aligned} {{m}_{j,t}}\ge \frac{1}{{{\mu }_{j}}-\frac{1}{D}}\sum \limits _{\delta \in \varPhi }{{{\lambda }_{\delta j,t}}},\forall j\in Q,t\in T \end{aligned}$$
(4)

Data Load Balancing Constraints. To ensure the stable and safe operation of the ship during entering and leaving from the port, the ship’s incoming and outgoing data loads must be consistent. A functional relationship between the data loads of shipboard data centers distributed at different power nodes is expressed as follows

$$\begin{aligned} {{L}_{\delta ,t}}=\sum \limits _{\delta \in \varPhi }{{{\lambda }_{\delta j,t}}},\forall j\in Q,\delta \in \varPhi ,t\in T \end{aligned}$$
(5)

Integer Constraints. Since the data loads of the ship and the number of servers in the shipboard data center are both integers, they are bounded by integers as follows

$$\begin{aligned} {{\lambda }_{\delta j,t}},{{m}_{j,t}} \ are \ positive \ integers,\forall j\in Q,t\in T\ \end{aligned}$$
(6)

In summary, according to Eqs. (1)–(6), the shipboard data center power consumption model can be obtained as

$$\begin{aligned} \begin{matrix} \min P_{ID{{C}_{j}},z}^{t}={{\theta }_{j}}{{m}_{j,t}}+{{\gamma }_{j}} \\ st:0<\frac{1}{{{\mu }_{j}}-\frac{\sum \nolimits _{\delta \in \varPhi }{{{\lambda }_{\delta j,t}}}}{{{m}_{j,t}}}}\le D \\ 0\le {{m}_{j,t}}\le {{M}_{j}} \\ {{L}_{\delta ,t}}=\sum \limits _{\delta \in \varPhi }{{{\lambda }_{\delta j,t}}} \\ {{\lambda }_{\delta j,t}},{{m}_{j,t}}\text { are positive integers} \\ \end{matrix} \end{aligned}$$
(7)

Power model conversion and packaging for shipboard data centers

Since we want to convert the decision variables into data loads, the active server can be represented by the shipboard data center power consumption according to Eq. (1) as

$$\begin{aligned} {{m}_{j,t}}=\frac{P_{ID{{C}_{j}},z}^{t}-{{\gamma }_{j}}}{{{\theta }_{j}}} \end{aligned}$$
(8)

(1) A constraint on the number of active servers in the shipboard data center can be converted from Eq. (2) to a constraint on the power consumption of the shipboard data center.

$$\begin{aligned} {{\gamma }_{j}}\le P_{ID{{C}_{j}},z}^{t}\le {{\theta }_{j}}{{M}_{j}}+{{\gamma }_{j}} \end{aligned}$$
(9)

(2) The shipboard data center data load processing latency constraint, i.e. Eq. (4), can be converted to

$$\begin{aligned} \frac{{{\mu }_{j}}-\frac{1}{D}}{{{\theta }_{j}}}\left( P_{ID{{C}_{j}},z}^{t}-{{\gamma }_{j}} \right) \ge \sum \limits _{\delta \in \varPhi }{{{\lambda }_{\delta j,t}}} \end{aligned}$$
(10)

where when the equal sign of Eq. (10) is taken, there is a minimum value \(P_{ID{{C}_{j}},z}^{t}\), noted as \(P_{ID{{C}_{j}},z,\min }^{t}\).

$$\begin{aligned} P_{ID{{C}_{j}},z,\min }^{t}=\frac{{{\theta }_{j}}}{{{\mu }_{j}}-\frac{1}{D}}\sum \limits _{\delta \in \varPhi }{{{\lambda }_{\delta j,t}}}+{{\gamma }_{j}} \end{aligned}$$
(11)

At this point, according to Eq. (8), the number of active servers is \({{m}_{j,t}}=\left( \sum \nolimits _{\delta \in \varPhi }{{{\lambda }_{\delta j,t}}} \right) /\left( {{\mu }_{j}}-1/D \right) \). Data load processing delay time of the shipboard data center j in the M/M/1 queuing model equals to the delay bound \(D=1/\left[ {{\mu }_{j}}-\left( \sum \nolimits _{\delta \in \varPhi }{{{\lambda }_{\delta j,t}}} \right) /{{m}_{j,t}} \right] \). The physical meaning of \(P_{ID{{C}_{j}},z,\min }^{t}\) that can be derived is the minimum power consumption value for a shipboard data center j to ensure the data load processing latency constraint. The physical meaning of \({{\theta }_{j}}/\left( {{\mu }_{j}}-1/D \right) \) is the minimum variable power consumption required to process a unit of data load in a shipboard data center j.

(3) Equation (6) is an integer constraint, where the conversion is applied. \(P_{ID{{C}_{j}},z,\min }^{t}\) is a discontinuous variable under this constraint. However, as each shipboard data center has tens of thousands of servers, the data loads that receive allocated processing in each time slot are massive, and the impact of power consumption from each server and data load is negligible. Therefore, it is approximately assumed that \(P_{ID{{C}_{j}},z,\min }^{t}\) is continuously variable, with the integer constraint \({{\lambda }_{\delta j,t}},{{m}_{j,t}}\) ignored.

This gives the converted expression for the shipboard data center power consumption model as

$$\begin{aligned} \left\{ \begin{matrix} P_{ID{{C}_{j}},z,\min }^{t}=\frac{{{\theta }_{j}}}{{{\mu }_{j}}-\frac{1}{D}}\sum \limits _{\delta \in \varPhi }{{{\lambda }_{\delta j,t}}}+{{\gamma }_{j}} \\ {{L}_{\delta ,t}}=\sum \limits _{\delta \in \varPhi }{{{\lambda }_{\delta j,t}}} \\ {{\gamma }_{j}}\le P_{ID{{C}_{j}},z}^{t}\le {{\theta }_{j}}{{M}_{j}}+{{\gamma }_{j}} \\ \end{matrix} \right. \end{aligned}$$
(12)

The shipboard data center power consumption model can be encapsulated according to Eq. (12) as

$$\begin{aligned} \left\{ \begin{matrix} P_{ID{{C}_{j}},z,\min }^{t}={{\phi }_{j}}\sum \limits _{\delta \in \varPhi }{{{\lambda }_{\delta j,t}}}+{{\gamma }_{j}} \\ {{L}_{\delta ,t}}=\sum \limits _{\delta \in \varPhi }{{{\lambda }_{\delta j,t}}} \\ {{\gamma }_{j}}\le P_{ID{{C}_{j}},z}^{t}\le {{\tau }_{j}} \\ \end{matrix} \right. \end{aligned}$$
(13)

where \({{\phi }_{j}}={{\theta }_{j}}/\left( {{\mu }_{j}}-1/D \right) \), \({{\tau }_{j}}={{\theta }_{j}}{{M}_{j}}+{{\gamma }_{j}}\).

In Eq. (13), \({{\phi }_{j}}\) is the minimum variable power consumption required to process a unit of data load in a shipboard data centerj, \({{\tau }_{j}},{{\gamma }_{j}}\) are the upper and lower limits of power consumption of the shipboard data center j respectively, \({{\phi }_{j}},{{\tau }_{j}},{{\gamma }_{j}}\) are parameters for the shipboard data center [28], which is [0.000015, 77.0, 2.0].

Energy management model

This paper proposes an energy management system for ships entering and leaving ports, as shown in Fig. 4. The system uses solar energy, wind energy and fuel oil generators to supply power to ships when ships are underway with the power supply mode being island mode. But when ships are docked, they are connected to the main port microgrid and simultaneously use shore power to supply power to ships. Therefore, the power supply mode is grid-connected. And batteries are added to improve the instability of new energy generation.

Fig. 4
figure 4

Energy management systems for ships entering and leaving ports

Objective function

The objective of this paper is to consider the economy of ships entering and leaving ports and the reduction of the carbon emissions from ships. In order to reduce the carbon emissions from ships, this paper considers the use of a carbon tax to increase the cost of using fossil energy to enable new energy ships to reduce their carbon emissions. At the same time, considering the computing resource requirements, the shipboard data center needs power supply. Therefore, the objective function consists of three parts: the cost of the ship operation, the cost of using shore power and the cost of carbon tax. The cost of shipboard data center is included in the cost of the ship operation.

$$\begin{aligned} F=\min \left\{ {{F}_{1}}+{{F}_{2}}+{{F}_{3}} \right\} \end{aligned}$$
(14)

where F is the total cost of the ship, \({{F}_{1}}\) is the cost of the ship operation, \({{F}_{2}}\) is the cost of shore power, and \({{F}_{3}}\) is the cost of the carbon tax.

The ship operation cost

This paper considers a new energy ship powered by photovoltaics, wind power, and fuel oil. When the ship is underway, the ship is powered by the ship’s power generation equipment, and when the ship is docked, the ship is powered by both the ship and shore power. Therefore, the new energy operating cost has four components, namely, wind power cost, photovoltaic power cost, fossil fuel power cost and battery cost.

$$\begin{aligned} {{F}_{1}}={{F}_{w}}+{{F}_{pv}}+{{F}_{fu}}+{{F}_{d}} \end{aligned}$$
(15)

where \({{F}_{w}}\) is the cost of wind power, \({{F}_{pv}}\) is the cost of photovoltaic power, \({{F}_{fu}}\) is the cost of fossil fuel power, and \({{F}_{d}}\) is the cost of the battery.

Thus, the cost functions of \({{F}_{w}}\), \({{F}_{pv}}\), \({{F}_{g}}\), \({{F}_{d}}\) are specified as follows [30]

$$\begin{aligned} {{F}_{w}}= & {} \sum \limits _{{{z}_{1}}=1}^{{{n}_{1}}}{{{a}_{{{z}_{1}}}}{{\left( {{P}_{w,{{z}_{1}}}} \right) }^{2}}+{{c}_{{{z}_{1}}}}} \end{aligned}$$
(16)
$$\begin{aligned} {{F}_{pv}}= & {} \sum \limits _{{{z}_{2}}=1}^{{{n}_{2}}}{{{a}_{{{z}_{2}}}}{{\left( {{P}_{pv,{{z}_{2}}}} \right) }^{2}}+{{c}_{{{z}_{2}}}}} \end{aligned}$$
(17)
$$\begin{aligned} {{F}_{fu}}= & {} \sum \limits _{{{z}_{3}}=1}^{{{n}_{3}}}{{{a}_{{{z}_{3}}}}{{\left( {{P}_{fu,{{z}_{3}}}} \right) }^{2}}+{{b}_{{{z}_{3}}}}{{P}_{fu,{{z}_{3}}}}+{{c}_{{{z}_{3}}}}} \end{aligned}$$
(18)
$$\begin{aligned} {{F}_{d}}= & {} \sum \limits _{{{z}_{4}}=1}^{{{n}_{4}}}{{{a}_{{{z}_{4}}}}{{\left( {{P}_{d,{{z}_{4}}}}+{{b}_{{{z}_{4}}}} \right) }^{2}}} \end{aligned}$$
(19)

where \({{P}_{w,{{z}_{1}}}}\) is the wind turbine output power, \({{P}_{pv,{{z}_{2}}}}\) is the photovoltaic output power, \({{P}_{g,{{z}_{3}}}}\) is the diesel generator output power, and \({{P}_{d,{{z}_{4}}}}\) is the battery output power. \({{a}_{{{z}_{1}}}}\), \({{a}_{{{z}_{2}}}}\), \({{a}_{{{z}_{3}}}}\), \({{a}_{{{z}_{4}}}}\), \({{c}_{{{z}_{1}}}}\), \({{c}_{{{z}_{2}}}}\), \({{c}_{{{z}_{3}}}}\), \({{b}_{{{z}_{3}}}}\), \({{b}_{{{z}_{4}}}}\) are the cost factors for power generation equipment, and \({{n}_{1}}\), \({{n}_{2}}\), \({{n}_{3}}\), \({{n}_{4}}\) are the number of individual generating units respectively.

The shore power cost

When a ship docks, the ship microgrid is connected to the port microgrid, and the ship’s power generation equipment and shore power together supply the ship with electricity. At this point, the energy management system for ships entering and leaving ports is in grid-connected mode, and shore power is more economical and green. The cost function of shore power is shown below.

$$\begin{aligned} {{F}_{2}}={{C}_{s}}{{P}_{s}} \end{aligned}$$
(20)

where \({{C}_{s}}\) is the cost factor for port shore power, and \({{P}_{s}}\) is the output power of the port microgrid.

The carbon tax cost

This paper uses a carbon tax to address the carbon emissions from ships and reduces the carbon emissions from ships by reducing fuel consumption.

$$\begin{aligned}{} & {} {{F}_{3}}={{C}_{C{{O}_{2}}}}{{M}_{C{{O}_{2}}}} \end{aligned}$$
(21)
$$\begin{aligned}{} & {} {{M}_{C{{O}_{2}}}}=\sum \limits _{{{z}_{3}}=1}^{{{n}_{3}}}{\eta }{{P}_{fu,{{z}_{3}}}} \end{aligned}$$
(22)

where \({{C}_{C{{O}_{2}}}}\) is the carbon tax price, \({{M}_{C{{O}_{2}}}}\) is the mass of carbon dioxide emitted from ships, and \(\eta \) is the coefficient of \(C{{O}_{2}}\) production from fossil fuel combustion. According to [31], the carbon tax price is set at 50.

Constraints

In order to ensure the stability and safety of ships entering and leaving ports during their operation, the following constraints are therefore required.

Computing Resource Constraints. In order to handle the data load while the ship is underway, the computing resources onboard must be sufficient and therefore the shipboard data center has to satisfy the following equation constraints.

$$\begin{aligned} \left\{ \begin{matrix} P_{ID{{C}_{j}},z,\min }^{t}={{\phi }_{j}}\sum \limits _{\delta \in \varPhi }{{{\lambda }_{\delta j,t}}}+{{\gamma }_{j}} \\ {{L}_{\delta ,t}}=\sum \limits _{\delta \in \varPhi }{{{\lambda }_{\delta j,t}}} \\ {{\gamma }_{j}}\le P_{ID{{C}_{j}},z}^{t}\le {{\tau }_{j}} \\ \end{matrix} \right. \end{aligned}$$
(23)

Power Balance Constraint. In order to ensure that the ship can operate properly while underway, the ship’s power generation must meet the demand for total load of the ship. Therefore, the ship microgrid has to satisfy the following equation constraints.

$$\begin{aligned} \begin{aligned}&\sum \limits _{{{z}_{1}}}^{{{n}_{1}}}{{{P}_{w,{{z}_{1}}}} +\sum \limits _{{{z}_{2}}}^{{{n}_{2}}}{{{P}_{pv,{{z}_{2}}}}} +\sum \limits _{{{z}_{3}}}^{{{n}_{3}}}{{{P}_{fu,{{z}_{3}}}}} +\sum \limits _{{{z}_{4}}}^{{{n}_{4}}}{{{P}_{d,{{z}_{4}}}}}}+{{P}_{M}} \\&\quad \qquad \qquad -{{P}_{IDC,z}}=\sum \limits _{z=1}^{n}{{{L}_{p,z}}} \\ \end{aligned} \end{aligned}$$
(24)

where N is the total number of ship’s power generation equipment, which meets \({{n}_{1}}+{{n}_{2}}+{{n}_{3}}+{{n}_{4}}=N\). And \({{L}_{p,z}}\) is the ship load demand.

Capacity Constraints on Generating Equipment.In order to ensure the safe operation of the power generation equipment on new energy ships, the generation capacity of the ship needs to be within certain limits, which can be expressed by the constraints as follows

$$\begin{aligned} \begin{aligned}&P_{w}^{\min }\le {{P}_{w,{{z}_{1}}}}\le P_{w}^{\max },P_{pv}^{\min }\le {{P}_{pv,{{z}_{2}}}}\le P_{pv}^{\max } \\&P_{fu}^{\min }\le {{P}_{fu,{{z}_{3}}}}\le P_{fu}^{\max },P_{d}^{\min }\le {{P}_{d,{{z}_{4}}}}\le P_{d}^{\max } \\ \end{aligned} \end{aligned}$$
(25)

where \(P_{w}^{\min },P_{w}^{\max },P_{pv}^{\min },P_{pv}^{\max },P_{fu}^{\min },P_{fu}^{\max },P_{d}^{\min },P_{d}^{\max }\) are the upper and lower power limits for wind turbine power generation equipment, photovoltaic power generation equipment, diesel power generation equipment and battery generation equipment, respectively.

Battery Capacity Constraints. Due to the presence of wind and photovoltaic power generation equipment on new energy ships that are characterised by instability in their power generation, batteries are added to the intelligent ship. There is a capacity limit on the amount of electricity generated by the batteries, which is constrained as follows

$$\begin{aligned} So{{C}_{\min }}\le 1-\frac{{{P}_{\text {d}}}}{{{P}_{e}}}\le So{{C}_{\text {max}}} \end{aligned}$$
(26)

where \({{P}_{e}}\) is the power rating of the battery, \(So{{C}_{\text {max}}}\) and \(So{{C}_{\min }}\) are the maximum and minimum state of charge of the battery onboard respectively.

Alternating direction method of multipliers (ADMM)-based distributed algorithm

Graph theory

The concerned ship microgrid with N equipment is in fact a multi-agent system with N agents. When the ship entering and leaving the port, it is in the island mode. And the communication topology of the multi-agent system can be represented by a directed graph \(G=\left\{ V,E,A \right\} \), where V is the set of nodes, which can be represented as \(V=\left\{ {{V}_{i}},i=1,2,3\cdots N \right\} \), E is the set of edges, which can be represented as \(E\subseteq V\times V\). A is the strengthened adjacency matrix of the graph, which can be represented as \(A=\left[ {{a}_{ij}} \right] \). In this directed graph G, all equipment nodes are connected, which can generate interaction between information flow and energy flow. If the agent i can pass information to the agent j, then there is a directed edge in the node \({{V}_{i}}\) and the node \({{V}_{j}}\), which can be represented as \({{V}_{i}},{{V}_{j}}\in E\). Next, the reinforced adjacency matrix can be defined as if \({{V}_{i}},{{V}_{j}}\in E\), then it can be expressed as \({{a}_{ij}}>0\). If \({{V}_{i}},{{V}_{j}}\notin E\), then it can be expressed as \({{a}_{ij}}=0\). Define the degree matrix as \(D=diag\left\{ {{d}_{1}},{{d}_{2}},{{d}_{3}}\cdots {{d}_{N}} \right\} \), where \({{d}_{i}}=\sum \nolimits _{i=1}^{N}{{{a}_{ij}}}\). Then the Laplacian matrix can be expressed as \(L=D-A\), and the Laplacian matrix can represent complex geometric structures. Moreover, when the ship is berthing at the port, it is in grid-connected mode and connected to shore power, then a leader agent is added to the multi-agent system.

Distributed algorithm in island mode

When a ship is running on the sea, the ship load is supplied by the power generation equipment on the ship. At this time, the ship’s energy management system is in island mode, and the leaderless distributed algorithm is used. In order to better solve the model established in this paper, the objective functions mentioned in “Energy management model” of this paper can be rewritten as the following equation.

$$\begin{aligned} {{F}_{i}}\left( {{P}_{i}} \right) =\frac{{{\left( {{P}_{i}}-{{\alpha }_{i}} \right) }^{2}}}{2{{\beta }_{i}}}+\varepsilon ,i=1,2,\cdots ,N \end{aligned}$$
(27)

where \({{\alpha }_{i}},{{\beta }_{i}},{{\varepsilon }_{i}} \) are all coefficients of the transformed cost function for the ship power generation equipment.

In this paper, the energy management problem of ships entering and leaving ports considering computing power resources can be rewritten as the following equation.

$$\begin{aligned} \begin{array}{l} \text {min}\sum \limits _{i=1}^{N}{{{F}_{i}}}\left( {{P}_{i}} \right) \\ st:\sum \limits _{i=1}^{N}{{{P}_{i}}}=\sum \limits _{i=1}^{N}{{{L}_{i}}} +\sum \limits _{i=1}^{N}{{{P}_{IDC,i}}}+\sum \limits _{i=1}^{N}{{{S}_{i}}P_{i}^{2}} \\ P_{i}^{\min }\le {{P}_{i}}\le P_{i}^{\max } \\ \end{array} \end{aligned}$$
(28)

where \({{S}_{i}}{{P}_{i}}^{2}\) is the network loss generated by the power generation equipment in the transmission process.

The Lagrangian function for the energy management problem above is

$$\begin{aligned}{} & {} L\left( {{P}_{i}},\lambda ,\bar{v},\underline{v} \right) =\sum \limits _{i=1}^{N}{\left( {{F}_{i}}\left( {{P}_{i}} \right) \right) } \nonumber \\{} & {} \quad +\lambda \left( \sum \limits _{i=1}^{N}{{{L}_{i}}}+\sum \limits _{i=1}^{N}{{{P}_{IDC,i}}} +\sum \limits _{i=1}^{N}{{{S}_{i}}P_{i}^{2}}-\sum \limits _{i=1}^{N}{{{P}_{i}}} \right) \nonumber \\{} & {} \quad +\bar{v}\left( {{P}_{i}}-P_{i}^{\max } \right) +\underline{v}\left( P_{i}^{\min }-{{P}_{i}} \right) \nonumber \\ \end{aligned}$$
(29)

If the function is continuously differentiable at a point \(P_{i}^{*}\), and \(P_{i}^{*}\) is a local minimum solution, then there exists a set of Lagrange multipliers \(\lambda ,\bar{v},\underline{v}\) such that

$$\begin{aligned} \left\{ \begin{array}{ll} {{\nabla }_{{{P}_{i}}}}L\left( P_{i}^{*},\lambda ,\bar{v},\underline{v} \right) =0 &{} \\ \sum \limits _{i=1}^{N}{{{L}_{i}}}+\sum \limits _{i=1}^{N}{{{P}_{IDC,i}}}+\sum \limits _{i=1}^{N} {{{\left( {{S}_{i}}P_{i}^{*} \right) }^{2}}}-\sum \limits _{i=1}^{N}{P_{i}^{*}}=0 &{} \\ P_{i}^{*}-P_{i}^{\max }\le 0 &{}\\ P_{i}^{\min }-P_{i}^{*}\le 0 &{}\\ \bar{v}\ge 0 &{} \\ \underline{v}\ge 0 &{} \\ \bar{v}\left( P_{i}^{*}-P_{i}^{\max } \right) =0 &{} \\ \underline{v}\left( P_{i}^{\min }-P_{i}^{*} \right) =0 &{} \\ \end{array} \right. \end{aligned}$$
(30)

The global optimal solution obtained is as follows

$$\begin{aligned} P_{i}^{*}=\left\{ \begin{array}{ccc} \frac{{{\alpha }_{i}}+\lambda {{\beta }_{i}}}{1+2{{S}_{i}}{{\beta }_{i}}\lambda } &{} {} &{} P_{i}^{\min }\le \frac{{{\alpha }_{i}}+\lambda {{\beta }_{i}}}{1+2{{S}_{i}}{{\beta }_{i}}\lambda }\le P_{i}^{\max } \\ P_{i}^{*,\max } &{} {} &{} \frac{{{\alpha }_{i}}+\lambda {{\beta }_{i}}}{1+2{{S}_{i}}{{\beta }_{i}}\lambda }>P_{i}^{\max } \\ P_{i}^{*,\min } &{} {} &{} \frac{{{\alpha }_{i}}+\lambda {{\beta }_{i}}}{1+2{{S}_{i}}{{\beta }_{i}}\lambda }<P_{i}^{\min } \\ \end{array} \right. \end{aligned}$$
(31)

where \(P_{i}^{*}\) is the global optimal solution of each power generation equipment.

In the island mode, the \(k+1\)th iteration electricity price is calculated by adding the penalty factor to obtain the incremental cost as follows

$$\begin{aligned} {{\lambda }_{i}}(k+1){} & {} ={{\lambda }_{i}}(k)+{{o}_{i}}\left[ \sum \limits _{j=1}^{N}{{{a}_{ij}}({{\lambda }_{j}}(k)-{{\lambda }_{i}}(k))}\right] \nonumber \\{} & {} \quad +\kappa \left( k \right) \varDelta \widehat{{{P}_{i}}}(k) \end{aligned}$$
(32)

where \({{o}_{i}}>0\) is the algorithm step size; \(\kappa (k)>0\) is the feedback gain; \(\varDelta \widehat{{{P}_{i}}}(k)\ \) is the kth iteration of the estimated local mismatch power.

According to Eq. (32), each generation unit uses \({{\lambda }_{i}}\left( k \right) \) to calculate the active power generated at the kth iteration as

$$\begin{aligned} P_i(k)= {\left\{ \begin{array}{ll}\frac{\alpha _i+\lambda _i(k) \beta _i}{1+2 S_i P_i \lambda _i(k)} &{} P_i^{\min } \le \frac{\alpha _i+\lambda _i(k) \beta _i}{1+2 S_i P_i \lambda _i(k)} \le P_i^{\max } \\ P_i^{\max } &{} \frac{\alpha _i+\lambda _i(k) \beta _i}{1+2 S_i P_i(k)}>P_i^{\max } \\ P_i^{\min } &{} \frac{\alpha _i+\lambda _i(k) \beta _i}{1+2 S_i P_i \lambda _i(k)}<P_i^{\min }\end{array}\right. } \end{aligned}$$
(33)

where \({{P}_{i}}(k)\) is the active power of the equipment at the kth iteration, calculated by iteration of \({{\lambda }_{i}}\).

Then, according to the local mismatch power is estimated, and the equation is as follows

$$\begin{aligned} \varDelta \widehat{{{P}_{i}}}(k+1)= & {} \varDelta \widehat{{{P}_{i}}}(k)+\rho \left[ \sum \limits _{j=1}^{N}{{{a}_{ij}}(\varDelta \widehat{{{P}_{j}}}(k)-\varDelta \widehat{{{P}_{i}}}(k))}\right] \nonumber \\{} & {} +\varDelta {{P}_{i}}(k+1)-\varDelta {{P}_{i}}(k)\nonumber \\ \end{aligned}$$
(34)

where \(\rho >0 \) is the algorithm step size; \(\varDelta {{P}_{i}}(k)\) is the actual local mismatch power at the kth iteration.

Based on the above analysis, when \({{o}_{i}}\in \left( 0,\frac{1}{\sum \nolimits _{j=0}^{N}{{{a}_{ij}}}}\right) \), \(\rho \in \left( 0,\frac{1}{{{\max }_{i=1,2,3...N}}\sum \nolimits _{j=0}^{N}{{{a}_{ij}}}}\right) \), \({{\lim }_{k\rightarrow \infty }}\kappa (k)=0\) and \(\sum \nolimits _{k=0}^{\infty }{\kappa (k)=\infty }\) are satisfied [32], for algorithms (32) - (34), there are \({{\lim }_{k\rightarrow \infty }}{{\lambda }_{i}}(k)=\lambda _{i}^{*},\text { }{{\lim }_{k\rightarrow \infty }}{{P}_{i}}(k)={{P}_{i}}^{*},\text { }{{\lim }_{k\rightarrow \infty }}\varDelta \widehat{{{P}_{i}}}(k)=0\). This means that in the island mode, the incremental cost and penalty factor converge to the electricity price of the microgrid, and follow the average consensus [33]. Thus, the optimal solution can be obtained, and the microgrid can achieve the balance of power supply and demand.

Distributed algorithm under grid-connected mode

When the ship is in shore, the ship microgrid is connected with the port microgrid, which is regarded as the grid-connected state. The port microgrid is regarded as the main power system, and the distributed algorithm with the leader agent is used in this case, the ship energy management problem can be written as follows

$$\begin{aligned} \begin{array}{l} \text {min}\sum \limits _{i=1}^{N}{{{F}_{i}}}\left( {{P}_{i}} \right) +{{\lambda }_{0}}{{P}_{M}} \\ st:\sum \limits _{i=1}^{N}{{{P}_{i}}}+{{P}_{M}}=\sum \limits _{i=1}^{N}{{{L}_{i}}} +\sum \limits _{i=1}^{N}{{{P}_{IDC,i}}}+\sum \limits _{i=1}^{N}{{{S}_{i}}P_{i}^{2}} \\ P_{i}^{\min }\le {{P}_{i}}\le P_{i}^{\max } \\ \end{array} \end{aligned}$$
(35)

The Lagrangian function for the energy management problem above is

$$\begin{aligned}{} & {} L\left( {{P}_{i}},\lambda ,\bar{v},\underline{v} \right) =\sum \limits _{i=1}^{N} {\left( {{F}_{i}}\left( {{P}_{i}} \right) \right) }+{{\lambda }_{0}}{{P}_{M}} \nonumber \\{} & {} +\lambda \left( \sum \limits _{i=1}^{N}{{{L}_{i}}}+\sum \limits _{i=1}^{N}{{{P}_{IDC,i}}} +\sum \limits _{i=1}^{N}{{{S}_{i}}P_{i}^{2}}-\sum \limits _{i=1}^{N}{{{P}_{i}}}-{{P}_{M}} \right) \nonumber \\{} & {} +\bar{v}\left( {{P}_{i}}-P_{i}^{\max } \right) +\underline{v}\left( P_{i}^{\min }-{{P}_{i}} \right) \nonumber \\ \end{aligned}$$
(36)

Because the distributed optimization algorithm with leader is used in the grid-connected mode, the value of \(\lambda \) shall be the same as that of the leader, that is, \(\lambda \) of each power generation equipment on the ship shall be equal to \(\lambda \) of the port microgrid. So that \(\lambda \) satisfies that following equation.

$$\begin{aligned} {{\lambda }^{*}}={{\lambda }_{0}} \end{aligned}$$
(37)

If the function is continuously differentiable at a point \(P_{i}^{*}\), and \(P_{i}^{*}\) is a local minimum solution, then there exists a set of Lagrange multipliers \(\lambda ,\bar{v},\underline{v}\) such that

$$\begin{aligned} \left\{ \begin{array}{ll} {{\nabla }_{{{P}_{i}}}}L\left( P_{i}^{*},\lambda ,\bar{v},\underline{v} \right) =0 &{} \\ \sum \limits _{i=1}^{N}{{{L}_{i}}}+\sum \limits _{i=1}^{N}{{{P}_{IDC,i}}} +\sum \limits _{i=1}^{N}{{{\left( {{S}_{i}}P_{i}^{*} \right) }^{2}}}-\sum \limits _{i=1}^{N}{P_{i}^{*}}-{{P}_{M}}=0 &{} \\ P_{i}^{*}-P_{i}^{\max }\le 0 &{} \\ P_{i}^{\min }-P_{i}^{*}\le 0 \\ \bar{v}\ge 0 &{} \\ \underline{v}\ge 0 &{} \\ \bar{v}\left( P_{i}^{*}-P_{i}^{\max } \right) =0 &{} \\ \underline{v}\left( P_{i}^{\min }-P_{i}^{*} \right) =0 &{} \\ \end{array} \right. \end{aligned}$$
(38)

Therefore, the global optimal solution in grid-connected mode can be obtained as follows

$$\begin{aligned} P_{i}^{*}= & {} \left\{ \begin{array}{ccc} \frac{{{\alpha }_{i}}+\lambda {{\beta }_{i}}}{1+2{{S}_{i}}{{\beta }_{i}}\lambda } &{} {} &{} P_{i}^{\min }\le \frac{{{\alpha }_{i}}+\lambda {{\beta }_{i}}}{1+2{{S}_{i}}{{\beta }_{i}}\lambda }\le P_{i}^{\max } \\ P_{i}^{*,\max } &{} {} &{} \frac{{{\alpha }_{i}}+\lambda {{\beta }_{i}}}{1+2{{S}_{i}}{{\beta }_{i}}\lambda }>P_{i}^{\max } \\ P_{i}^{*,\min } &{} {} &{} \frac{{{\alpha }_{i}}+\lambda {{\beta }_{i}}}{1+2{{S}_{i}}{{\beta }_{i}}\lambda }<P_{i}^{\min } \\ \end{array} \right. \end{aligned}$$
(39)
$$\begin{aligned} P_{M}^{*}= & {} \sum \limits _{i=1}^{N}{{{P}_{i}}}-\sum \limits _{i=1}^{N}{{{L}_{i}}} \end{aligned}$$
(40)

where \(P_{i}^{*}\) is the global optimal solution of each power generation equipment, and \(P_{M}^{*}\) is the optimal solution of port power generation capacity, i.e. the power generation capacity of the main power grid.

In the grid-connected mode, the iterative method of electricity price follows the leader-following consensus, and the iterative process is as follows

$$\begin{aligned} \begin{aligned} {{\lambda }_{i}}(k+1)&={{\lambda }_{i}}(k)+{{o}_{i}}^{\prime }\left[ \sum \limits _{j=1}^{N}{{{a}_{ij}} ({{\lambda }_{j}}(k)-{{\lambda }_{i}}(k))}\right. \\&\left. +{{a}_{i0}}({{\lambda }_{0}}-{{\lambda }_{i}}(k))\right] \\ \end{aligned} \end{aligned}$$
(41)

where \({{o}_{i}}'>0\) is the algorithm step size.

According to Eq. (41), the active power generated by each generation unit can be obtained by the following equation.

$$\begin{aligned} P_i(k)= {\left\{ \begin{array}{ll}\frac{\alpha _i+\lambda _i(k) \beta _i}{1+2 S_i P_i \lambda _i(k)} &{} P_i^{\min } \le \frac{\alpha _i+\lambda _i(k) \beta _i}{1+2 S_i P_i \lambda _i(k)} \le P_i^{\max } \\ P_i^{\max } &{} \frac{\alpha _i+\lambda _i(k) \beta _i}{1+2 S_i P_i(k)}>P_i^{\max } \\ P_i^{\min } &{} \frac{\alpha _i+\lambda _i(k) \beta _i}{1+2 S_i P_i \lambda _i(k)}<P_i^{\min }\end{array}\right. } \end{aligned}$$
(42)

where \({{P}_{i}}(k)\) is the active power of the equipment at the kth iteration, calculated by \({{\lambda }_{i}}\) iteration.

Then, according to the actual local mismatch power, the estimated local mismatch power of all nodes in the microgrid are as follows

$$\begin{aligned} \left\{ \begin{aligned} {{g}_{i}}\left( k+1 \right) =&\varDelta \widehat{P}_i(k)+\rho ^{\prime }\left[ \sum _{j=1}^N a_{i j}\left( \varDelta \widehat{P}_j(k)-\varDelta \widehat{P}_i(k)\right) \right] \\&+\varDelta P_i(k+1)-\varDelta P_i(k) \\ \varDelta \widehat{P}_i(k+1)=&\left( 1-a_{0 j}\right) {{g}_{i}}\left( k+1 \right) \end{aligned}\right. \nonumber \\ \end{aligned}$$
(43)

where \(\rho '>0 \) is the algorithm step size; \(\varDelta \widehat{{{P}_{i}}}(k)\ \) is the kth iteration of the estimated local mismatch power; \(\varDelta {{P}_{i}}(k)\) is the actual local mismatch power at the kth iteration.

The active power exchange between the port’s shore power and the ship’s microgrid is as follows

$$\begin{aligned} P_{M}^{{}}(k+1)=P_{M}^{{}}(k)+\sum \limits _{i=n}^{N}{{{a}_{0i}}{{g}_{i}}(k+1)} \end{aligned}$$
(44)

where \({{P}_{M}}(k+1)\) is the power supplement value of shore power to adjacent nodes at the kth iteration.

After the above analysis, when \({{o}_{i}}'\in \left( 0,\frac{1}{\sum \nolimits _{j=0}^{N}{{{a}_{ij}}}}\right) \) and \(\rho ' \in \left( 0,\frac{1}{{{\max }_{i=1,2,3...N}}\sum \nolimits _{j=0}^{N}{{{a}_{ij}}}}\right) \) are satisfied [32], for algorithms (4144), there are \({{\lim }_{k\rightarrow \infty }}{{\lambda }_{i}}(k)=\lambda (0), \text { }{{\lim }_{k\rightarrow \infty }}{{P}_{i}}(k)={{P}_{i}}^{*}, \text { }{{\lim }_{k\rightarrow \infty }}\varDelta \widehat{{{P}_{i}}}(k)=0,\text { }{{\lim }_{k\rightarrow \infty }} {{P}_{M}}(k)= P_{M}^{*}\). Based on this, in the grid-connected mode, the optimal solution can be obtained, by which the balance between the energy supply and demand of the ship is achieved.

Simulation

In this case, Matlab is used to verify the effectiveness of the proposed distributed energy management method for ships entering and leaving ports. In the simulation cases, the topology of the power generation equipment in the considered ships entering and leaving ports is shown in Fig. 3, and the parameters of the power generation equipment are shown in Table 1. When the ship is sailing, the ship microgrid is in island mode comprising two photovoltaic power generation equipment (agent 1 and agent 2 in Fig. 5), two wind power generation equipment (agent 3 and agent 4 in Fig. 5), two fuel generators (agent 5 and agent 6 in Fig. 5), a shipboard data center (agent 7 in Fig. 5) and an energy storage equipment (agent 8 in Fig. 5), but shore power (agent 0) is not comprised. When the ship is in shore, the ship microgrid is in grid-connected mode, so the ship microgrid is connected with the shore power supply (agent 0) to supply power for the ship together. In island mode, the overall load of the ship is 120 MW, the network loss generated by the power generation equipment during power transmission is \({{S}_{i}}{{P}_{i}}^{2}\), and the network loss coefficient \({{S}_{i}}\) of each power generation equipment is [0.0023, 0.0023, 0.0019, 0.0019, 0.0013, 0.0013, 0.0019]. In the simulation cases, 90 iterations are set in total, where the first 30 iterations are the sailing process of the ship, the 30th–60th iterations are the berthing process of the ship, and the 60th–90th iterations are the departure process of the ship from the port. The simulation results are shown in Figs. 6, 7, 8, 9, 10.

Table 1 Parameters of the equipment
Fig. 5
figure 5

Communication topology

Island mode

In this case, assuming that the ship is sailing in island mode between 8:00 a.m. and 9:00 a.m., the power consumption of the shipboard data center is 6MW, and the energy management model is constructed as (28). The centralized algorithm [30] is adopted to solve the problem, the power supply of each generator set is [16.38, 19.28, 14.92, 24.81, 21.90, 16.38, 17.20], as shown in Fig. 6. And the network loss generated by the ship power generation equipment is 4.60MW, the carbon emission is 33.03t, the carbon emission cost is 1651.59¥, generation of the ship is 130.87MW. The operation cost of the ship is 120,560¥.

Fig. 6
figure 6

Simulation results of centralized algorithm for ship power generation in island mode

Under the same conditions, based on the distributed algorithm in this paper, the incremental cost of each power generation equipment converges to \(\lambda =0.51\) uniformly at \(k=200\), as shown in Fig. 7a. At this time, the power supply of each generator set is [16.03, 18.94, 14.55, 24.46, 21.50, 18.20, 16.84], as shown in Fig. 7b. The network loss generated by the ship’s power generation equipment is 4.53 MW, the carbon emission of the ship is 27.08t, and the carbon emission cost is 1354¥. The estimated power mismatch value converges to zero at \(k=200\), as shown in Fig. 7c. The total generating capacity of the ship is 130.52 MW, and the ship operation cost is 116,630¥, as shown in Fig. 7d. During the navigation of ships, a large amount of carbon dioxide will be generated due to the combustion of fossil fuels. When the generated carbon dioxide is processed, the carbon tax will be generated, resulting in the increase of the ship operation cost. Therefore, based on the constructed energy management model, ships use less fossil fuels and prioritize clean energy. By comparison, the results of the distributed algorithm are consistent with the centralized algorithm, which shows the accuracy of the distributed algorithm in this paper.

Fig. 7
figure 7

Simulation results of distributed algorithm for ship in island mode

Enter and leave port mode

Port Entering Mode. In this case, it is assumed that between 8 a.m. and 9 a.m., the ship completes the process of entering and leaving the port, and the shipboard data center consumes 6 MW. After entering the port and berthing, the ship will be in grid connection mode, and the ship will be connected to the port microgrid, \({{P}_{M}}\) is the power provided by the port microgrid for the ship. In addition, the ship’s load is reduced by 26.52 MW due to the closing of the ship’s navigation equipment, while the load is increased by 24.89 MW due to the opening of the loading and unloading equipment by the docked ship. When the ship is connected to the grid at the shore, the energy management model is shown as (32), which is solved by the distributed algorithm. It can be seen from Fig. 8a that when the ship is docked and connected to the grid at \(k=500\), the incremental cost of the final power generation equipment converges to \(\lambda =0.48\) at \(k=800\). At this time, the power supply of each generator unit is [12.42, 15.38, 10.69, 20.75, 17.35, 14.01, 13.01, 25.29], as shown in Fig. 8b. The network loss generated by ship power generation equipment is 2.90 MW, the carbon dioxide emitted by the ship is 20.45t, and the carbon emission cost is 1022.5¥. It can be seen from Fig. 8c that during the process of entering the port and berthing, it passes through 520 iterations, and the estimated power mismatch value converges to 0 again after rapid adjustment. The total generating capacity of the ship is 128.89 MW, and the operating cost is 204,860¥, as shown in Fig. 8d. It can be seen that since shore power is more economical and green, the output power of the ship ’s power generation equipment becomes less and the shore power output power is more when berthing.

Fig. 8
figure 8

Simulation results of ship power generation in port entering mode

Port Leaving Mode. In this case, when the ship is sailing away from the port, the ship energy management system changes from the grid connection mode to the island mode, where the ship loading and unloading equipment is closed, so that the ship load decreases by 24.89MW, and the navigation equipment is opened, so that the ship load increases by 26.52MW. The ship energy management model is shown as (28), which is solved by using the distributed algorithm. As shown in Fig. 9a, when \(k=500\), the ship leaves the port, and the incremental cost of each power generation equipment converges to \(\lambda =0.51\) at \(k=800\). It can be seen from Fig. 9b that the power supply of each equipment is [12.41, 15.37, 10.68, 20.75, 17.34, 14.00, 13.00, 25.34] when leaving the port. Power supply of each equipment after switching back to island mode is [12.42, 15.38, 10.69, 20.75, 17.35, 14.01, 13.01, 25.29]. The net loss generated by the ship power generation equipment is 2.90 MW, the carbon emission is 27.07t, and the carbon emission cost is 1353.5¥. As shown in Fig. 9c, after the switching, the mismatch value of the ship fluctuates briefly, and after 600 iterations, the estimated power mismatch value of the ship microgrid converges to 0 again quickly after adjustment. The total power generation of the departure ship is 128.89 MW, and the operation cost is 116,130¥. When sailing on an island mode, the total power generation of the ship is 130.52 MW, and the operation cost is 116,630¥, as shown in Fig. 9d

Fig. 9
figure 9

Simulation results of ship power generation in port leaving mode

Through the comparison and analysis of the two sets of simulation results, it can be seen that the carbon emission of the ship using shore power to supply power for the ship after the ship is docked is obviously reduced, compared with that of the ship during navigation. At the same time, the operation cost of ships entering ports is much higher than that leaving the port. The reason is that when the ship is docked, the ship preferentially uses more economical and environment-friendly shore power to supply power to the ship, so the carbon emission content is reduced, resulting in the obvious reduction of operation cost.

Equipment troubleshooting mode

In this case, it is assumed that the ship is in island navigation mode between 8:00 a.m. and 9:00 a.m.. The power consumption of the shipboard data center is 6 MW, the ship power generation equipment FU1 has a fault and needs to be repaired, and the ship enters the equipment troubleshooting mode. The energy management model is as shown in (28), which is solved based on the proposed distributed algorithm. When \(\text {k}=230\), the ship power plant FU1 fails and is shut down for maintenance. When \(\text {k}=350\), the ship incremental cost converges again to \(\lambda =0.54\), as shown in Fig. 10a. The amounts of power supplied by the remaining power plants PV1, W1, STO, PV2, W2, FU2 are [18.48, 21.35, 0, 26.98, 24.34, 21.07, 19.44], as shown in Fig. 10b. The network loss generated by the ship power generation equipment is 5.28 MW, the carbon emission is 16.77t, and the carbon emission cost is 838.5¥. When one of the ship’s diesel generators fails, the output power of the remaining power generation equipment is increased while reaching the upper limit of its own power generation. As shown in Fig. 10c, after the failure of FU1, the estimated power mismatch value reaches to 15 and fluctuates greatly. After 300 iterations, the estimated power mismatch value converges to 0 again, meeting the demand for ship supply and balance. As shown in Fig. 10d, the total power generation of the ship is 131.66 MW, and the ship operation cost is 169,340¥. Compared with the conventional island mode, the ship operation cost increases by 52,710¥, but due to less fossil fuel combustion and more use of clean energy, the ship carbon emission is greatly reduced, and the carbon emission cost is reduced accordingly.

Fig. 10
figure 10

Simulation results of ship power generation in equipment troubleshooting mode

Power consumption of shipboard data center

The shipboard data center is an important load on the ship. Assuming that there are two shipboard data centers on the ship, only one is started and one is standby, so as to ensure sufficient computing resources of the ship. In the above simulation cases, it is assumed that the simulation period is from 8:00 a.m. to 9:00 a.m., the load of ship operation data is 266,700 number/s, and the power consumption of the shipboard data center is calculated to be 6MW based on the power consumption model of the shipboard data center as shown in (13). In order to obtain the power consumption of the shipboard data center in each time period, the data load generated in the process of receiving the ship sailing data from the front end of the shipboard data center is given, as shown in Table 2. As the data load generated during the operation of the ship is variable [28], the power generation capacity of the power generation and energy storage equipment on the ship changes accordingly to meet the load demand of the shipboard data center, which increases the ship operation cost, as shown in Table 3.

Table 2 Ship operation data load

Conclusion

This paper has proposed a polymorphic distributed energy management method for ships entering and leaving the port considering computing power resources. Firstly, a polymorphic network-based energy management system for ships entering and leaving ports has been proposed to enhance the information exchange between ship computing power, power and port power, which improves the communication quality and communication security among different modes. Secondly, in order to reduce the ship operating costs and port carbon emissions, the energy management model of ships entering and leaving ports has been constructed. Then, according to the ship’s berthing and departing operation modes, this paper has used the distributed algorithm to solve the energy management problem, and explored the impact on the ship microgrid when the ship’s data load changes. Finally, the simulation results verify the effectiveness of the proposed polymorphic distributed energy management method for ships entering and leaving ports considering computing power resources.

Table 3 Operation cost per time period of a shipboard data center

In the future, low-carbon green ships and ports including clean energy are the development direction, which are with the multi-energy network. To improve the efficiency of comprehensive utilization of multiple energy sources, the research on distributed energy management strategies to solve the energy management problem with coupling constraints requires concern.