ufechner7 / kitemodels.jl Goto Github PK
View Code? Open in Web Editor NEWKite and tether models for the simulation of kite power systems
Home Page: https://ufechner7.github.io/KiteModels.jl/
License: MIT License
Kite and tether models for the simulation of kite power systems
Home Page: https://ufechner7.github.io/KiteModels.jl/
License: MIT License
Currently the value of max_steering is hardcoded:
const KS = deg2rad(16.834) # max steering in degrees
Instead, the value of the settings file should be used.
An example how to use the model from Python would be useful for some users.
@JuliaRegistrator register
This is a bit more involved then for the 3 point model because not for all particles the y position is zero. Two particles have a y position that is not zero, but they must be symmetric which means y_C=-y_D .
Is there any possibility to simulate a kite that has 3 wires going from the ground to the kite, so using three ground-based motors, instead of using a control pod in the air? If so, how could one implement this?
Add a page in the documentation how to use it.
Use vortex step method to characterize kite aerodynamically, lumping the forces into 3 nodes.
Current code:
function calc_acc_speed(tether_speed::SimFloat, norm_::SimFloat, set_speed::SimFloat)
calc_acceleration(AsyncMachine(se("system_3l.yaml")), tether_speed, norm_; set_speed, set_torque=nothing, use_brake=false)
end
The settings should be added as parameter.
Add a constructor SysState(s::AKM).
A SysState object is needed for easy display of the state in KiteViewers.
The requires to calculate the orientation as quaternion. Perhaps first add a function orient(s::AKM).
In order to make the kps4_3l accurate without having to fly a real kite, the Xfoil.jl package should be used to find lift and drag coefficients for different aoa and different steering amounts.
If you see that different wind speeds change the trim angle of the kite, have you tried increasing the stiffness only of the lines that would represent the bridle system?
That would constrain the kite structure in a more realistic way, I think.
Replace the code inside of this package with the functions from AtmosphericModels.
Current testing is happening only with a 6 segment tether which is not sufficient.
Add the 4 point model to the code base. Add a type hierarchy that makes it possible to swap the active model easily.
Some things are not clear to me regarding the state initializations in Kitemodels.jl . In find_steady_state!
, why do we have s.stiffness_factor=stiffness_factor
and then s.stiffness_factor=1.0
?
Also I do not really get why find_steady_state_inner
is called twice ?
Thanks in advance for your help.
This issue is used to trigger TagBot; feel free to unsubscribe.
If you haven't already, you should update your TagBot.yml
to include issue comment triggers.
Please see this post on Discourse for instructions and more details.
If you'd like for me to do this for you, comment TagBot fix
on this issue.
I'll open a PR within a few hours, please be patient!
Given the C_l and C_d polars, calculate what would be the optimal aoa of the kite for optimal lift vs drag.
The function next_step! has the parameter wind_dir
, which is defined such that zero means wind from west to east. This is not a standard way to define the wind direction.
Replace this parameter with upwind_direction as defined here: https://ufechner7.github.io/KiteUtils.jl/dev/reference_frames/
It should not be required.
The steering sensitivity depends on:
all of them defined in settings.yaml.
Write a script that visualizes the result, e.g. the side force or torque as function of the steering input.
And function copy_examples()
Use these values instead of hard-coded values.
initial:
...
depower: 25.0 # initial depower settings [%]
solver:
abs_tol: 0.0006 # absolute tolerance of the DAE solver [m, m/s]
rel_tol: 0.001 # relative tolerance of the DAE solver [-]
max_iter: 200 # max number of iterations of the steady-state-solver
When running the reset() and get_next_step() functions I very rarely get the error:
[IDAS ERROR] IDACalcIC
Newton/Linesearch algorithm failed to converge.
This is happening while Reinforcement Learning. So I run the reset once, and then run get_next_step until the kite crashes (around 285 times). That is one episode, and this is repeated x times.
I get the error for the first time after around 76 episodes (each running reset once, and get_next_step 285 times on average).
One episode pseudocode:
reset()
while not crashed:
get_next_step(action)
Output.txt containing the rollout of one episode and the first occurrance error:
---------------------------------
| rollout/ | |
| ep_len_mean | 285 |
| ep_rew_mean | -200 |
| time/ | |
| episodes | 76 |
| fps | 456 |
| time_elapsed | 84 |
| total_timesteps | 38448 |
| train/ | |
| actor_loss | 4.3e+11 |
| critic_loss | 3.32e+23 |
| ent_coef | 2.06e+10 |
| ent_coef_loss | -437 |
| learning_rate | 0.0456 |
| n_updates | 768 |
---------------------------------
[IDAS ERROR] IDACalcIC
Newton/Linesearch algorithm failed to converge.
Environment.jl:
module Environment
using Timers; tic()
using KiteModels
using KiteUtils
# using PyCall #removed pycall!!
# using Plots
const Model = KPS4
set_data_path(joinpath(@__DIR__, "../../Simulator/data"))
kcu = KCU(se());
kps4 = Model(kcu);
dt = 1/se().sample_freq
steps = 1000
step = 0
logger = Logger(se().segments + 5, steps)
GC.gc();
toc();
integrator = KiteModels.init_sim!(kps4, stiffness_factor=0.04);
function get_next_step(depower, steering)
global step
depower = Float32(depower)
steering = Float32(steering)
v_ro = 0.0
if depower < 0.22; depower = 0.22; end
set_depower_steering(kps4.kcu, depower, steering)
t_sim = 0.0
open("next_step_io.txt", "w") do io
redirect_stdout(io) do
t_sim = @elapsed KiteModels.next_step!(kps4, integrator, v_ro=v_ro, dt=dt)
end
end
GC.gc(false)
sys_state = SysState(kps4)
step += 1
return sys_state.orient[1], sys_state.orient[2], sys_state.orient[3], sys_state.orient[4], sys_state.force
end
function reset()
global kcu
global kps4
global integrator
global step
global sys_state
update_settings()
save_log(logger)
kcu = KCU(se());
kps4 = Model(kcu);
integrator = KiteModels.init_sim!(kps4, stiffness_factor=0.04)
step = 0
sys_state = SysState(kps4)
GC.gc();
return sys_state.orient[1], sys_state.orient[2], sys_state.orient[3], sys_state.orient[4], sys_state.force
end
function render()
global sys_state, logger, step, steps
if(step < steps)
log!(logger, SysState(kps4))
end
end
end
System:
I am running the code on IDUN High Performance Computing: https://www.hpc.ntnu.no/idun/
inside an apptainer ubuntu container.
I made a system image with Environment as a precompiled package.
The winch controller is already integrated in KPS4, but not yet in KPS3.
TODO:
If the latest version of system.yaml is not present in the folder data precompiling KiteModels fails.
If exported as functional mockup unit (FMU) using the FMI for Co-Simulation interface, then the model could also be used in other simulation environments like Simulink or OpenModellica. An FMU is a zip file which contains a dll/.so file and an interface description in XML format.
At some point in time this should be possible using the Julia package https://github.com/ThummeTo/FMIExport.jl , but this type of export is not yet supported. See: ThummeTo/FMIExport.jl#10
Update the links at the bottom of
https://github.com/ufechner7/KiteModels.jl/edit/main/docs/src/index.md
The functions rad_cl_mtk
and rad_cd_mtk
are not part of the model struct and can therefore not be changed after pre-compilation. This should be fixed as it was already done for KPS4 and KPS3. This has no negative impact on the performance.
Integrate the winch model to achieve a realistic dynamics when the reel out speed is not constant.
The winch model is implemented in a separate package: https://github.com/aenarete/WinchModels.jl
But it still has to be integrated here.
Currently the kite model requires a winch model that has a set speed as input. Modern winches often have a set torque as input. Using such a winch model requires a new, optional interface.
Add functions for KPS3 and KPS4 to determine the orientation of the kite.
Under the assumption that the KCU is a sphere it would be easy to model its drag. This should be added.
https://www1.grc.nasa.gov/beginners-guide-to-aeronautics/drag-of-a-sphere/
https://www.efunda.com/formulae/fluids/calc_reynolds.cfm#calc
Re = 8.67 e5 for v_a=30 m/s and 0.4m diameter
Cd ~ 0.3
Add a non-allocating version of the function SysState(kps::AKM)
with the signature
update_sys_state!(sys_state, kps::AKM, zoom=1.0)
to reduce memory allocations
Make it possible to mount the kite power system on a moving vehicle, e.g. for ship propulsion.
Add a field version to both KPS3 and KPS4.
Version 1 shall be compatible with the original Python code, version 2 shall include bug fixes and improvements.
Add functions to calculate the heading and the course.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.