navitron
 
Renewable Energy and Sustainability Forum
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Anyone wishing to register as a new member on the forum is strongly recommended to use a "proper" email address - following recent spam/hack attempts on the forum, all security is set to "high", and "disposable" email addresses like Gmail, Yahoo and Hotmail tend to be viewed with suspicion, and the application rejected if there is any doubt whatsoever
 
Recent Articles: Navitron Partners With Solax to Help Create A More Sustainable Future | Navitron Calls for Increased Carbon Footprint Reduction In Light of Earth Overshoot Day | A plea from The David School - Issue 18
   Home   Help Search Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: php help required!  (Read 5840 times)
Ivan
Hero Member
*****
Offline Offline

Posts: 2262


« on: August 23, 2010, 04:09:07 PM »

I've written a SAP calculator for Solar thermal output in PHP. We're planning to put it on the Navitron website for anyone to use (I've seen some solar SAP calculators on the web available for a 150/yr licence fee!!)

My SAP calculator works perfectly in one PHP editor (DZSoft PHP Editor), it doesn't work in the other I tried (PHPEdit v3.6.4). I've saved it as a 'html' file and the php code is between <?php and ?>  I've also copied the file to webspace on one of my websites, but it doesn't work properly there.

Any suggestions? Whereas I'm sure the problem is down to my incompetence, I can't think of a purpose for PHPeditors if they can't test whether the page works/displays correctly!
Logged

www.epogee.co.uk - Solar PV & Solar Thermal Training / MCS
stephendv
Hero Member
*****
Offline Offline

Posts: 928



WWW
« Reply #1 on: August 23, 2010, 04:22:59 PM »

I'll be happy to test it.  stephendv at gmail.com
Logged

http://www.casanogaldelasbrujas.com
2.8kW PV, SMA Sunny Island 5048, 5 PzS 700 battery bank, stinky diesel.
martin
Hero Member
*****
Offline Offline

Posts: 15733



WWW
« Reply #2 on: August 23, 2010, 04:23:13 PM »

there's a good "developers" plugin for Firefox to try all sorts of stuff like that! Smiley
Logged

Unpaid volunteer administrator and moderator (not employed by Navitron) - Views expressed are my own - curmudgeonly babyboomer! - http://www.farmco.co.uk
hiccup
Sr. Member
****
Offline Offline

Posts: 305


« Reply #3 on: August 23, 2010, 05:36:21 PM »

Hi Ivan

Assuming the webspace you tested it on is PHP enabled, the file will probably need to be saved as a .php to make the server parse it and spit out the html. The browser will access foo.php but will never see any of the php code.

HTH

Hic!
Logged

16 x Sanyo HIT250E01 into SB4000TL inverter, 2 x 20 x 58mm Navi Tubes on 22deg roof facing SSE, Gledhill Torrent RE Solar 277litre Store, TDC4 Ether Controller, Xpelair Xcell400BP HRV, Stovax Riva 66 Wood Burner
stephendv
Hero Member
*****
Offline Offline

Posts: 928



WWW
« Reply #4 on: August 24, 2010, 08:57:49 AM »

The only way to be sure it works is to upload and test it on a server.  When you say that it doesn't work when uploaded, what exactly is it doing or not doing.
Logged

http://www.casanogaldelasbrujas.com
2.8kW PV, SMA Sunny Island 5048, 5 PzS 700 battery bank, stinky diesel.
Ted
Global Moderator
Hero Member
*****
Offline Offline

Posts: 3907



« Reply #5 on: August 24, 2010, 10:07:57 AM »

Do you really need php to do this? I would've thought that Javascript calc'ing in the browser (with maybe XML data download in the background -  Google have a really simple API for that with php pulling SQL data and formatting to XML) would be enough?  I've experience of doing all that.

Most issues I've found with php are to do with changes between different versions, usually v4 and v5.

I can test/debug on my webhost as well if you want, but only under php v5.
Logged

Volunteer moderator
Ivan
Hero Member
*****
Offline Offline

Posts: 2262


« Reply #6 on: August 24, 2010, 03:56:18 PM »

I've PM'd the code to Ted and Stephend, Martin. I'm happy to email it to Hiccup if you're interested.

I want to make this available for everyone to use on the Navitron website, but I don't want to post the code here - because no doubt one of our competitors will simply pinch it and put it onto their website.

Let me know what you guys think. I've done the donkey work in php now, so I guess it's best to keep it as php instead of javascript. I'm also keen to avoid using SQL databases, because we've used quite a lot of them, and our webserver package provides a limited number of databases, and I think we're at maximum already. Also, I thought it was a good opportunity to learn something potentially useful.

The code is very basic at the moment - it's not intended to go live before it's prettied up. In its current form it echos the various intermediate constants for the SAP calculation mainly as a way to help identify bugs.
Logged

www.epogee.co.uk - Solar PV & Solar Thermal Training / MCS
hiccup
Sr. Member
****
Offline Offline

Posts: 305


« Reply #7 on: August 24, 2010, 04:17:58 PM »

Hi Ivan

Sure, PM it to me too. I can run it here on my development server. and let you know what I find.

Hic!
Logged

16 x Sanyo HIT250E01 into SB4000TL inverter, 2 x 20 x 58mm Navi Tubes on 22deg roof facing SSE, Gledhill Torrent RE Solar 277litre Store, TDC4 Ether Controller, Xpelair Xcell400BP HRV, Stovax Riva 66 Wood Burner
Ted
Global Moderator
Hero Member
*****
Offline Offline

Posts: 3907



« Reply #8 on: August 24, 2010, 09:37:46 PM »

Loaded onto my server and seems to work OK. My php version is 5.2.13.

Results from a simple test:
Code:
SFB20-47
Collector Characteristics = 1.25; 0.599; 2.417; 0.01
Aap = 1.25
S = 1042 kWh/m2/year
Calculation Results
-------------------
Company Name:   test
Location =   (Annual Radiation per m2 of collector S= 1042 kWh/yr)
Overshading Factor 1.0
Tilt Angle = 30
Veff = 155.4
Vd = 129.32
Total Floor Area= 120
Variable 'N' = 3.6528
Daily Hot Water Demand = 129.32
Box39 (Energy Content of Water Used (kWh/yr): 2344.1556768
Box40 (Distribution Losses (kWh/yr): 413.6745312
BoxH7 (Solar Energy Available (kWh/yr): 780.1975
BoxH8 (Solar-to-Load Ratio): 0.28290265939389
Utilisation Factor = 0.97083496527757
collector performance factor 0.73522904841402
Variable 'fveffvd' = 1.0367424970153

Anticipated Solar input (as defined by SAP2005) = 577.35578555588 kWh/year

If you need to keep the calculations under wraps then php is going to be a better option than Javascript.

BTW if you need some extra simple SQL databases then you can just use SQLite which is effectively already built-in to php (should be enabled by default). These shouldn't count against any allocation of MySQL dbs that you may have with your host. I have a couple of sites running this way with WordPress using the PDO driver and it works like a dream.
Logged

Volunteer moderator
wookey
Hero Member
*****
Offline Offline

Posts: 3221


WWW
« Reply #9 on: August 24, 2010, 09:56:59 PM »

Perhaps I'm old-fashioned but I prefer server-side calcs over client-side. I like things that still work without javascript. Of course it should be all ajaxy or jsony these days.

Well done Ivan. I started writing such a thing, but didn;t get very far as I ended up just using a spreadsheet.

Sounds like you have enough volunteers but I can help out by taking a look too. Not sure about your idea that an editor should be able to run software intended for a web-server.

Do please consider making it FLOSS. More proprietary implementations of this doesn't really advance the world much, even if you are making the app interface publically visible.

I'm very interested in providing software for loads of this stuff. There is a great swathe of useful building-design type software which is Windows only, proprietary and expensive, despite being fundamentally quite simple. But I haven't yet found a group of people working to fix this.

I've written quite a fancy spreadsheet to do eurocode 5 timber beam and post calculations, for example, which isn't quite as nice as Greentram's Superbeam, or forthcoming eurobeam, but does the job. The task isn't well-suited to spreadsheets and would be much better implemented as a more directed inteface. SAP calcs is a good example of a simple target. U-value calculators is another. We've done various solar thermal calculators on this site too.

It'd be really nice to provide something as good as PHPP for house thermal design, and last week I found dewpoint3 which is a simple windows app (for GBP 175!) which implements BSsomething-or-other for dewpoint calcs. Something that could do some of what TRNSYS does but for less than $2000 would be really useful too. There are loads more. CH calculators (how many of those have you seen), sizing tools for woodburners, pellet boilers, hot water tanks etc etc.

None of this is rocket science (actually the eurocode stuff is quite rockety - it took me weeks, but many tasks are simple). There really should be Free Software available for this - either as apps, or online. Preferably both. The bit I get stuck on is how to implement the architecture for such things. It would be nice to have some kind of structure so you could tie thing together, and re-use libraries - e.g. having described a wall you could do U-value calcs _and_ dewpoint calcs without having to enter all the info again. And whilst spreadsheets have their uses and are accessible I really don't think it's the way to provide nice interfaces, or maintainable code (despite the remarkable example of PHPP whic his about as good as it gets). I beleive it's called 'Building Information Modelling' at the fancy end.

So, does anyone already know of a group that is working on this stuff that I could join, or am I going to have to start something? Is anyone else interested in making such a thing happen, and more importantly have relevant software expertise?

I guess I might try to find some people interested in this at OpenTech on 11th Sept.

Hmm, I seem to have got a little over-excited there and come over all wyleu, but this has been bugging me for a while.
Logged

Wookey
Ivan
Hero Member
*****
Offline Offline

Posts: 2262


« Reply #10 on: August 25, 2010, 04:13:57 AM »

Thanks for the input from everyone.

Wookey, I'm wholeheartedly in favour of open-source software, but I'm not keen on competitors using stuff that we've developed to help sell their competing products. Where the product is the software itself, open-source works well, but where the software is helping to sell another product, it doesn't work so well (unless I'm missing something here). Hence the preference for making it freely available to everyone to use, but without actually giving it away to competitors. It seems a bit cheeky that some companies are offering 150/year licences to use a similar SAP2005 solar calculator software, given the tiny amount of work involved - it took me two days to write it, and most of that time I was learning php. If I had written  it in BASIC, it would have taken me about two hours (sadly, it's the only language that I ever learnt).

I'm quite keen to develop similar calculators when I get the time, so I'm certainly interested in joint efforts. Of course, I've not got a great deal to offer in this respect - my programming ability is lousy.


A big THANK YOU to Stephendv who has corrected a couple of things and got it up and running on a server. If Stephen is happy to post his link (I don't want to do so without his permission), you can all have a look at it. I'll try to make it a bit prettier when I get chance.
Logged

www.epogee.co.uk - Solar PV & Solar Thermal Training / MCS
stephendv
Hero Member
*****
Offline Offline

Posts: 928



WWW
« Reply #11 on: August 25, 2010, 08:11:55 AM »

http://www.casanogaldelasbrujas.com/sap2005_v1.php

 Smiley
Logged

http://www.casanogaldelasbrujas.com
2.8kW PV, SMA Sunny Island 5048, 5 PzS 700 battery bank, stinky diesel.
wookey
Hero Member
*****
Offline Offline

Posts: 3221


WWW
« Reply #12 on: August 26, 2010, 02:52:02 PM »

Wookey, I'm wholeheartedly in favour of open-source software, but I'm not keen on competitors using stuff that we've developed to help sell their competing products. Where the product is the software itself, open-source works well, but where the software is helping to sell another product, it doesn't work so well (unless I'm missing something here).

So to paraphrase your words above: you are all in favour of FLOSS when you get to use other people's work, but you aren't in favour of it when you have done some of your own work (and thus have the opportunity to give something back)?

The point is that by opening up the software everyone gets to benefit. Yes that includes your competitors, but this is not a zero-sum game. Overall we all get better software at reasonable cost, without artificial 'anti-features' (ad-ware, pointless upgrades, use restrictions) and we all get where we are going faster. The benefit of getting a healthy ecosystem of building-design software going is much greater (in the long term) than the benefit of you having stuck up a free SAP web page a few months before some other people do. You need to think about the whole process and ecosystem, not just this one bit of software. It's not hard to re-implement it, as you say yourself. I've already done most of it, you've done, it, so can lots of other people so the benefit of keeping it closed is pretty small. The benefit to you is having it running on your site, attracting users, and possibly some customisations suggesting your products as solutions. You can do that just as well under the Affero GPL as under a proprietary licence.

Some has already done an online SAP calc for the solar thermal part: http://www.valentin.de/calculation/sap/

Knauf did have a whole-house SAP calc online but it seems to have gone now. There really is a gaping hole in the market here. The tricky bit is that we run up against the usuall 'accreditation' boll*cks. No-one can use your SAP calculator for real work until you've paid around GBP 1000 to the BRE to get it accredited. This is a real hurdle for Free Software, but one we should make a fuss about, and a good reason why some kind of income stream or pledge system may be needed in order to get it certified.
Logged

Wookey
Pat_
Sr. Member
****
Offline Offline

Posts: 467



« Reply #13 on: August 28, 2010, 11:08:19 AM »

I tried out the calculator (Ivan's), and for my inputs it gave me 800kWh. As it happens my wife mentioned that our installation (30x47mm tubes) is a couple of weeks off a year old, and the controller says around 700kWh at the moment. (I calibrated it based on heating a tank from cold one day.) So the calculator seems to be useful.
Logged
clivejo
Guest
« Reply #14 on: September 06, 2010, 08:14:51 PM »

Hi,

May I have a look at the code? 

Thanks,
Clive
Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.20 | SMF © 2013, Simple Machines
SMFAds for Free Forums
Simple Audio Video Embedder
Valid XHTML 1.0! Valid CSS!