Python Forum
unable to use result of solver in another function
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
unable to use result of solver in another function
#1
Hi , I've used the sp.solveset function to calculate a variable.

so solveset gives me a value of 11.34.. for b . I then want to use b as 11.34.. in the formula for w and for the mean. This doesn't seem to be working and I'm having to input this manually.

#This imports various libraries
import matplotlib.pyplot as plt
import numpy as np
import sympy as sp
from scipy.integrate import simps
from numpy import trapz
import math
from sympy.solvers import solve


V_cutin=4 #m/s
Mean_windspeed=10.054113100183285 #m/s
V_cutout=25 #m/s

#linspace creates an array from 0-25 with 26 intervals. cutout speed+1=26

x=np.linspace(0,25,26)
#print(x)

#y is power results from Blade element theory, enter manually. value 26 is power at 25m/s this should be 0 as turbine is cut out.

y=[0,0,0,0,0.0488,0.6955,1.6501,2.8708,4.4371,6.3941,8.000,8.000,8.000,8.000,8.000,8.000,8.000,8.000,8.000,8.000,8.000,8.000,8.000,8.000,8.000,0.000]
#print( len(y), "= number of values in y") # this should be equal to cut out speed +1
#print(y)


a=2 # weibul shape factor

c=sp.symbols("c")
b=sp.solveset((c*np.exp(math.lgamma(1+1/2)))-Mean_windspeed,c)
#print(b)


#b=11.3448517658689 #weibul shape factor , use solveset function above to determine and then manually enter here.
mean=b*np.exp(math.lgamma(1+1/a))

print("The weibul scale factor is =", a)
print("The weibul shape factor is =", b)
print("The mean of the distribution is =", mean)

w=a/b**a*x**(a-1)*np.exp(-(x/b)**a) #weibul PDF function 
#print(x) displays "x-axis" (wind speeds)
#print(w) displays "y-axis" (probabilities)
I'm unable to use the b variable and get the following errors :

This error is relating to mean formula

TypeError: Arguments to ProductSet should be of type Set Wall

This error is relating to w formula

TypeError: unsupported operand type(s) for /: 'int' and 'ProductSet' Wall

any help would be greatly appeciated.

Cheers
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Unable to get function to do anything... ejwjohn 8 890 Nov-07-2023, 08:52 AM
Last Post: ejwjohn
  Sudoku Solver in Python - Can someone explain this code ? qwemx 6 2,147 Jun-27-2022, 12:46 PM
Last Post: deanhystad
  Sudoku Solver, please help to solve a problem. AdithyaR 5 2,135 Oct-28-2021, 03:15 PM
Last Post: deanhystad
  building a sudoku solver usercat123 7 2,777 Oct-01-2021, 08:57 PM
Last Post: deanhystad
  How to use function result in another function Ayckinn 4 2,844 Jun-16-2020, 04:50 PM
Last Post: Ayckinn
  Pandas's regular expression function result is so strange cools0607 6 3,198 Jun-15-2020, 07:34 AM
Last Post: cools0607
  Trouble with Sudoku Solver Techmokid 2 2,159 Apr-08-2020, 07:55 AM
Last Post: Techmokid
  Confusion with datetime 'dst' function result jsmith1703 4 3,356 Nov-16-2019, 02:55 AM
Last Post: DeaD_EyE
  Passing Values of Dictionaries to Function & Unable to Access Them firebird 3 2,597 Aug-03-2019, 10:25 PM
Last Post: firebird
  editing lists / sudoku solver monagro 5 4,070 May-29-2018, 02:16 PM
Last Post: monagro

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020