Jump to content

[1.4.x] Solar Cycle Simulator Recycled! v1.1.0.1, 4 Jun 2018


Recommended Posts

Solar Cycle Simulator (SCS) - Recycled!

Note:  Due to the prolonged absence of @Whitecat106, I took it upon myself to revive this mod.  It is a required dependency to Orbital Decay, another mod I adopted recently.  In order to properly maintain support of Orbital Decay, I decided to bring this mod up to date and properly source control it for future support within the community.  I have attempted to contact @Whitecat106 to inform him of my intentions.  Since the license allows it, Here we are.  I make no promises as to how much I can expand on this mod, but @Whitecat106 did leave a bit of info in his original thread about the direction he was heading.  If you have ideas, please share, and code contributions are welcome.

_____________________________________________________________________________________
Original Author @Whitecat106
Original Thread:  Solar Cycle Simulator Dev thread

Current Maintainer:  @Papa_Joe
_____________________________________________________________________________________

 

From Whitecat:

Hello everyone! Whitecat here, creator of the Historic Missions contract pack, Orbital Decay plugin and the Boat Navigation Plugin. Here I present to you a small project which I required as an addon to my Orbital Decay mod.

 

This plugin simply generates and tracks the constantly changing solar cycles of the sun, this can be used in conjunction with RSS or a Stock game.

gIl0ITt.png

 

This however is more of a tool for modders than an actual plugin, installed on its own it will simply track and display information on the solar cycle in the Tracking Station, but together with some programming skills a mod maker could create accurate (realistic) solar flare, coronal mass ejection, solar storm or other interesting solar activity based plugins.

For Players:

Simply download the pack and install the GameData folder into your GameData directory; remember this does not add much apart from a small tracking station UI! (It is also a dependency of Orbital Decay).

Download:

GitHub:  Download

Source Code:  Source Code

Original Mod Download from Whitecat106:  Dropbox

For Mod Makers:

Download the pack from the link above and install into your GameData directory, remember that this pack will be a dependency of any mods you create using it, so ensure you provide a link to this page for the latest release. You can include the latest version of this plugin as a reference in your C# development project, from this you will be able to access the following functions: (limited at the moment I know, but bear with me and I will add some more!) The following can be retrievied by using for example:

SCSManager.FetchCurrentF107()

or

SCSManager.FetchCurrentAp()

 

Here are the available functions:

  Reveal hidden contents
 public static double FetchCurrentF107()
        {
                string Temp = FetchCurrentCycle().GetValue("CurrentF107");
                double F107 = double.Parse(Temp);
                return F107;
        }

        public static double FetchCurrentAp()
        {
                double Ap = double.Parse(FetchCurrentCycle().GetValue("CurrentAp"));
                return Ap;
        }

        public static double FetchAverageF107()
        {
            double F107 = 0.0;
            double F1071 = double.Parse(FetchCurrentCycle().GetValue("MaxF107"));
            double F1072 = double.Parse(FetchCurrentCycle().GetValue("MinF107"));
            F107 = (F1071 + F1072) / 2;
            return F107;
        }

        public static double FetchAverageAp()
        {
            double Ap = 0.0;
            double Ap1 = double.Parse(FetchCurrentCycle().GetValue("MaxAp"));
            double Ap2 = double.Parse(FetchCurrentCycle().GetValue("MinAp"));
            Ap = (Ap1 + Ap2) / 2;
            return Ap;
        }

        public static double FetchCurrentIPMF()
        {
            double IPMF = double.Parse(FetchCurrentCycle().GetValue("CurrentIPMF"));
            return IPMF;
        }

        public static double FetchCurrentIrradiance()
        {
            double Irradiance = double.Parse(FetchCurrentCycle().GetValue("CurrentIrradiance"));
            return Irradiance;
        }

        public static double FetchCurrentSunSpots()
        {
            double SunSpots = double.Parse(FetchCurrentCycle().GetValue("CurrentSunSpots"));
            return SunSpots;
        }

 

Of course there are more Static functions in the code but these will require a little digging into the source but it should be relatively easy for anyone to find anything you are looking for!

As I said this is a little bare-bones at the moment, I will include more functions as time progresses and if anyone takes an interest in this small tool!

This mod now includes a version file and supports KSP-AVC  

License:

This code is licensed under the Attribution-NonCommercial-ShareAlike 3.0 (CC BY-NC-SA 3.0) creative commons license.   License.txt

Edited by Papa_Joe
new version
Link to post
Share on other sites

New release to correct some bugs.

Version 1.1.0.1 - 4 Jun 2018
 - Correct settings file path names
 - Clean up disallowed constructor var assignments due to new Unity version.
 - Correct urls for version file.
 

Link to post
Share on other sites
2 hours ago, Gordon Dry said:

@Papa_Joe I get confused.

The embedded SCS inside the Orbital Decay release has a total different file and folder structure than this standalone release.

So what?

The old version of the mod had a folder name of SCS.  the latest versions released by me use a name of SolarCycleSimulator.  the SCS.DLL is no longer used.  So, if you simply overwrite an existing install (for example the KSP 1.3.1 install)  you will end up with 3 folders under the WhitecatIdustries folder in GameData.  while that "might" not break the game, it does mean an additional DLL is loaded, consuming memory.

Link to post
Share on other sites
  • 3 weeks later...

@Papa_Joe it seems that on each session or even on each vessel loaded into flight mode a new solar cycle begins.

Perhaps this is the reason for the orbit again decaying 0.1m every few seconds?

NullReferenceException: Object reference not set to an instance of an object
  at WhitecatIndustries.Source.StationKeepingManager.EngineCheck (.Vessel vessel) [0x00000] in <filename unknown>:0 
  at WhitecatIndustries.Source.StationKeepingManager.FuelManager (.Vessel vessel) [0x00000] in <filename unknown>:0 
  at WhitecatIndustries.Source.DecayManager.FixedUpdate () [0x00000] in <filename unknown>:0 
 
(Filename:  Line: -1)

cPRlC0Y.png

 

Edited by Gordon Dry
Link to post
Share on other sites
40 minutes ago, Gordon Dry said:

@Papa_Joe it seems that on each session or even on each vessel loaded into flight mode a new solar cycle begins.

Perhaps this is the reason for the orbit again decaying 0.1m every few seconds?

NullReferenceException: Object reference not set to an instance of an object
  at WhitecatIndustries.Source.StationKeepingManager.EngineCheck (.Vessel vessel) [0x00000] in <filename unknown>:0 
  at WhitecatIndustries.Source.StationKeepingManager.FuelManager (.Vessel vessel) [0x00000] in <filename unknown>:0 
  at WhitecatIndustries.Source.DecayManager.FixedUpdate () [0x00000] in <filename unknown>:0 
 
(Filename:  Line: -1)

...

This is not related to the solar cycle, but it is an issue...

How often is the error occurring? can you provide a link to a log with this error?  It will help me locate it.

Edited by Papa_Joe
Link to post
Share on other sites
22 minutes ago, Papa_Joe said:

How often is the error occurring? can you provide a link to a log with this error?  It will help me locate it.

First I had this issue before I added Orbital Decay, but it was gone after I added it.

Previously it only happened in low orbit.

A few days ago it reappeared, I couldn't pinpoint it to any other mods.

Also with drift compensation true or false doesn't change anything.

Now it also happens in high orbit.

Here is the log:
https://www.dropbox.com/s/v7zs6nqfo7cpu36/2018-06-23_1%20KSP.log.7z?dl=1

Link to post
Share on other sites

@Papa_Joe  I wonder if you could make this mod compatible with Copernicus, that way it would become compatible with most planet packs. You can achieve it by importing the Copernicus configuration file and apply it to your simulation. That way I could properly apply it to KSPIE Magnetic scoop solar wind collector , solar power collectors and  Photon Sailor solar sail.

Edited by FreeThinker
Link to post
Share on other sites

@Papa_Joe

Could you please tell me how to retieve the following information from the Solar Cycle Simulator

1 The current solar light flux as a percentage from normal average solar light flux

2 The current solar wind flux as a percentage from normal average solar wind flux

3 The current solar wind speed as a percentage from normal average solar wind speed

Edited by FreeThinker
Link to post
Share on other sites
  • 1 year later...

@FreeThinker did you end up ever working this into KSPIE/Photon Sailor for later KSP versions? @Sir Mortimer has anyone ever considered working this into Kerbalism? I haven't been able to find any updated thread and I don't expect this to be merged directly into either these mods so I'm pretty sure the answer from both of you will be no but just double checking

Link to post
Share on other sites
2 hours ago, Drew Kerman said:

@FreeThinker did you end up ever working this into KSPIE/Photon Sailor for later KSP versions? @Sir Mortimer has anyone ever considered working this into Kerbalism? I haven't been able to find any updated thread and I don't expect this to be merged directly into either these mods so I'm pretty sure the answer from both of you will be no but just double checking

As an option, yes - but not as a dependency. Ideally it would just replace Kerbalisms bare bone solar activity simulation. However, it would need support for multiple suns (Kopernicus) - well as a current release (not sure how much this is required after the .net and unity update in KSP 1.8)

As far as I can tell, FetchCurrentAp could affect the size+strength of the magnetosphere, FetchCurrentIrradiance would affect solar panels (not sure if the effect would be big enough to make a difference in game play) and FetchCurrentSunSpots would affect the probability of solar flares.

 

Link to post
Share on other sites

I'd like to also include support for this mod in Kerbal Health as I was just about to start implementing a rather simplified version of a solar cycle. I just don't want to depend on thus mod being maintained and recompiled for every KSP update. So either have it as an optional dependency or, better, being able to include (some parts of) the source code would be great.

Link to post
Share on other sites
Just now, Drew Kerman said:

cool, well if you and the team decide to work it in, that would be neat-o and maybe also help bring along someone to pickup the orbital decay mod that could also pull from this data

You would also need someone to pick up this mod, solar cycle simulator. Just from speed reading the code I see several issues that need to be adressed: The API needs to be extended for Kopernicus support and it would have to simulate different cycles for different suns, and there are a couple of performance optimizations to be made, especially when considering API usage via reflection. Also, I might be mistaken, but this looks to be writing current state to GameData/WhitecatIndustries/SolarCycleSimulator/Plugins/PluginData/Data.cfg instead of the saved game state, which is a big no no for obvious reasons.

That said, what this mod does is it calculates min/max values for a number of parameters and multiplies those values by a cosine that covers one full cycle. This isn't much different from what Kerbalism does. The only benefit I see in this is that you would see changes in things that are affected by solar activity that are consistent across different mods, i.e. the orbit will decay faster while you see more solar flares in kerbalism. 

Link to post
Share on other sites
37 minutes ago, Sir Mortimer said:

This isn't much different from what Kerbalism does

I figured as much, which is why I was saying you could take inspiration from it to extend what Kerbalism does. I realize now that I misread your "as an option" statement - you meant Kerbalism could support this mod if it was installed with it, not as something you'd consider covering with Kerbalism itself?

Link to post
Share on other sites
1 hour ago, Drew Kerman said:

I figured as much, which is why I was saying you could take inspiration from it to extend what Kerbalism does. I realize now that I misread your "as an option" statement - you meant Kerbalism could support this mod if it was installed with it, not as something you'd consider covering with Kerbalism itself?

Yes, but still this would make perfect sense. If there is a game-wide provider of solar activity, it would be good if Kerbalism used that one instead of relying on its own, because then the overall game behaviour would be more coherent.

Edited by Sir Mortimer
Link to post
Share on other sites
  • 5 months later...
  • 4 weeks later...
On 8/19/2020 at 5:19 PM, techmaster077 said:

Do you know if this is compatible with Principia and Kerbalism? What changes would have to be made, etc.?

Orbital Decay is not an issue for Kerbalism, but it will not work with Principia.

Link to post
Share on other sites
This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...