# Very cold environment causes error?

**URL:** https://discourse.kitware.com/t/very-cold-environment-causes-error/576
**Category:** Pulse Physiology Engine
**Created:** [December 14, 2020, 8:11pm UTC](https://discourse.kitware.com/t/very-cold-environment-causes-error/576 "2020-12-14T20:11:58Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![bob.marinier](https://discourse.kitware.com/letter_avatar_proxy/v4/letter/b/7ab992/32.png) [@bob.marinier](https://discourse.kitware.com/u/bob.marinier)
#### Post date: [December 14, 2020, 8:11pm UTC](https://discourse.kitware.com/t/very-cold-environment-causes-error/576/1 "2020-12-14T20:11:59Z")

</div>

I’m trying to get a patient to be hypothermic as quickly as possible (understanding that pulse currently makes this hard). So I made a copy of the SubmergedFreezing.json environment (SubmergedSuperFreezing.json) where the only change was to reduce the `AmbientTemperature`. It seems that 5 deg C works, but if I use 4 deg C or lower I get this error:

```auto
FATAL:Resistance cannot be negative or zero. : ClothingToEnvironment

```

What’s going on here? Is it a bug or something else?

---

<div class="post-metadata">

### Author: ![bob.marinier](https://discourse.kitware.com/letter_avatar_proxy/v4/letter/b/7ab992/32.png) [@bob.marinier](https://discourse.kitware.com/u/bob.marinier)
#### Post date: [December 14, 2020, 8:27pm UTC](https://discourse.kitware.com/t/very-cold-environment-causes-error/576/2 "2020-12-14T20:27:54Z")

</div>

If I keep `AmbientTemperature` at 5 deg C and change `ClothingResistance` to 0.0, I get a different error:

```auto
FATAL:Resistance cannot be negative or zero. : ExternalSkinToClothing
FATAL:Attempting to populate a matrix with an infinite value. Check ExternalSkinToClothing path circuit element. : 

```

According to [wikipedia](https://en.wikipedia.org/wiki/Clothing_insulation) a value of 0 means “naked body”, which seems like it should be valid.

---

<div class="post-metadata">

### Author: ![abray](https://discourse.kitware.com/user_avatar/discourse.kitware.com/abray/32/12_2.png) [@abray](https://discourse.kitware.com/u/abray)
#### Post date: [December 14, 2020, 8:28pm UTC](https://discourse.kitware.com/t/very-cold-environment-causes-error/576/3 "2020-12-14T20:28:05Z")

</div>

Looks like a bug at this line  
[https://gitlab.kitware.com/physiology/engine/-/blob/master/src/cpp/cpm/environment/Environment.cpp#L627](https://gitlab.kitware.com/physiology/engine/-/blob/master/src/cpp/cpm/environment/Environment.cpp#L627)

should be:

```auto
dResistance_K_Per_W = MAX(dResistance_K_Per_W, m_data.GetConfiguration().GetDefaultClosedHeatResistance(HeatResistanceUnit::K_Per_W));

```

That 2nd FATAL is also a bug  
Looks like I just need to do the MAX on that resistance too

---

<div class="post-metadata">

### Author: ![abray](https://discourse.kitware.com/user_avatar/discourse.kitware.com/abray/32/12_2.png) [@abray](https://discourse.kitware.com/u/abray)
#### Post date: [December 14, 2020, 8:38pm UTC](https://discourse.kitware.com/t/very-cold-environment-causes-error/576/5 "2020-12-14T20:38:44Z")

</div>

@coolwebb

What is the minimum clothing resistance a human can have?  
If this is 0, the resistance becomes 0  
Which is not good…

[https://gitlab.kitware.com/physiology/engine/-/blob/master/src/cpp/cpm/environment/Environment.cpp#L232](https://gitlab.kitware.com/physiology/engine/-/blob/master/src/cpp/cpm/environment/Environment.cpp#L232)

Note, using the default closed heat resistance, still craps out the resistance. Seems like we need a minimum, non zero clothing resistance, or a better minimum resistance value for this path…

```auto
//Set clothing resistor
double dClothingResistance_rsi = GetEnvironmentalConditions().GetClothingResistance(HeatResistanceAreaUnit::rsi); //1 rsi = 1 m^2-K/W
double dSurfaceArea_m2 = m_data.GetCurrentPatient().GetSkinSurfaceArea(AreaUnit::m2);
double SkinToClothingResistance_K_Per_W = MAX(dClothingResistance_rsi / dSurfaceArea_m2, m_data.GetConfiguration().GetDefaultClosedHeatResistance(HeatResistanceUnit::K_Per_W));
m_SkinToClothing->GetNextResistance().SetValue(SkinToClothingResistance_K_Per_W, HeatResistanceUnit::K_Per_W);

```

---

<div class="post-metadata">

### Author: ![coolwebb](https://discourse.kitware.com/user_avatar/discourse.kitware.com/coolwebb/32/25_2.png) [@coolwebb](https://discourse.kitware.com/u/coolwebb)
#### Post date: [December 15, 2020, 3:11pm UTC](https://discourse.kitware.com/t/very-cold-environment-causes-error/576/6 "2020-12-15T15:11:00Z")

</div>

There was a numerical solver issue with a zero clothing resistance. The fixes to this and the other issues previously mentioned were just pushed to the 3.x branch.

Thanks for finding these! Let us know if you find any other issues.

---

<div class="post-metadata">

### Author: ![bob.marinier](https://discourse.kitware.com/letter_avatar_proxy/v4/letter/b/7ab992/32.png) [@bob.marinier](https://discourse.kitware.com/u/bob.marinier)
#### Post date: [December 15, 2020, 5:13pm UTC](https://discourse.kitware.com/t/very-cold-environment-causes-error/576/7 "2020-12-15T17:13:49Z")

</div>

Thanks! I did file a couple issues in the repo issue tracker, but if you’d rather I bring up that stuff here I can do that. I’ve been trying to separate questions about how to use the system, which I post here, from actual issues, which I post there. In this case, I wasn’t sure if there was an issue with the system or if I was just doing it wrong, so I posted here. But maybe I should always post here because more people will see it and could comment on it?

---

<div class="post-metadata">

### Author: ![abray](https://discourse.kitware.com/user_avatar/discourse.kitware.com/abray/32/12_2.png) [@abray](https://discourse.kitware.com/u/abray)
#### Post date: [December 15, 2020, 5:56pm UTC](https://discourse.kitware.com/t/very-cold-environment-causes-error/576/8 "2020-12-15T17:56:56Z")

</div>

I don’t think we have a “right way” of interacting with the community (you!)  
We are still a pretty small community, so its pretty free form…  
I think posting here is fine to have more of a discussion, but also posting an issue on something that is more or less a bug, described, simple reproducible, etc. is good on the issue tracker.

Since we have had some discussions with creating a cold environment, discourse is a good place since Pulse does have some issues with the environment/energy concerning this use case.

I think your approach to communication is pretty good.  
I just need to find time to dig into the issues.  
This one was pretty quick since all I had to do is run the HowTo environment with one modification in C++ and I hit your error really quickly, and noticed the problem

I should probably be more responsive on the issues that I acknowledge the issue as being good and that I am going to look into it…
